def testDataReceived(self):
     self.assertNotEqual(self.protocol,None)
     threads.blockingCallFromThread(reactor,self.protocol.dataReceived,"This is a test line")
     threads.blockingCallFromThread(reactor,self.protocol.transport.loseConnection)
     unity.wait(0.1)
     f = open("testing.txt","r")
     self.assertNotEqual(f,None)
     l = f.readline()
     self.assertEqual(l,"This is a test line")
     f.close()
 def testDataReceived(self):
     self.assertNotEqual(self.protocol,None)
     threads.blockingCallFromThread(reactor,self.protocol.transport.write,"Start something")
     threads.blockingCallFromThread(reactor,self.protocol.transport.loseConnection)
     unity.wait(0.1)
     f = open("testingout.txt","r")
     self.assertNotEqual(f,None)
     for i in range(0,100):
         l = f.readline()
         self.assertEqual(l,"This is a test line" + str(i) +"\n")
     f.close()
Beispiel #3
0
 def tearDown(self):
     # The waiting here is important to ensure there is time for all tests
     # to finish.
     unity.wait(1)
     unity.wrapBlocking(self.protocol.transport.loseConnection)
     pass