move towards single implementation for socket client/server using asyncore and threads
This commit is contained in:
34
test.py
Normal file
34
test.py
Normal file
@@ -0,0 +1,34 @@
|
||||
from mysocket import TcpClient, TcpServer
|
||||
import time
|
||||
import unittest
|
||||
|
||||
class TestTcpCommunication(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.server = TcpServer('', 10000)
|
||||
self.client = TcpClient('localhost', 10000)
|
||||
|
||||
self.server.start()
|
||||
self.client.start()
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
self.client.stop()
|
||||
self.server.stop()
|
||||
|
||||
def test_tcp_communication(self):
|
||||
for i in range(1, 50):
|
||||
self.server.send('server #%d' % i)
|
||||
time.sleep(1)
|
||||
|
||||
for i in range(1, 50):
|
||||
self.client.send('client #%d' % i)
|
||||
time.sleep(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
testList = [TestTcpCommunication]
|
||||
suite = unittest.TestLoader().loadTestsFromTestCase(unittest.TestCase)
|
||||
for testCase in testList:
|
||||
suite.addTest(unittest.makeSuite(testCase))
|
||||
result = unittest.TestResult()
|
||||
suite.run(result)
|
||||
print result
|
||||
Reference in New Issue
Block a user