move towards single implementation for socket client/server using asyncore and threads

This commit is contained in:
2015-09-06 22:48:23 +01:00
parent 97613337c6
commit ba882d7e2b
18 changed files with 158 additions and 243 deletions

34
test.py Normal file
View 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