Small cleanups to test_nonblockingtcp.py without much value.

This commit is contained in:
Stephan Erb 2008-12-24 14:46:21 +00:00
parent c5aff6f37c
commit 53d1fa6f66

View file

@ -3,9 +3,8 @@ Unit test for NonBlockingTCP tranport.
''' '''
import unittest import unittest
from xmpp_mocks import * from xmpp_mocks import IdleQueueThread, IdleMock
import sys, os.path
import threading, sys, os.path, time
gajim_root = os.path.join(os.path.abspath(os.path.dirname(__file__)), '..') gajim_root = os.path.join(os.path.abspath(os.path.dirname(__file__)), '..')
@ -22,12 +21,14 @@ Script will connect to the machine.
''' '''
import socket import socket
ips = socket.getaddrinfo(xmpp_server[0], xmpp_server[1], socket.AF_UNSPEC,socket.SOCK_STREAM) ips = socket.getaddrinfo(xmpp_server[0], xmpp_server[1],
socket.AF_UNSPEC,socket.SOCK_STREAM)
# change xmpp_server on real values # change xmpp_server on real values
ip = ips[0] ip = ips[0]
class MockClient(IdleMock): class MockClient(IdleMock):
def __init__(self, idlequeue): def __init__(self, idlequeue):
self.idlequeue = idlequeue self.idlequeue = idlequeue
IdleMock.__init__(self) IdleMock.__init__(self)
@ -70,12 +71,14 @@ class TestNonBlockingTCP(unittest.TestCase):
self.idlequeue_thread.stop_thread() self.idlequeue_thread.stop_thread()
self.idlequeue_thread.join() self.idlequeue_thread.join()
def testSth(self): def test_connect_disconnect(self):
self.client.do_connect() self.client.do_connect()
self.assert_(self.client.socket.state == 'CONNECTED') self.assert_(self.client.socket.state == 'CONNECTED')
self.client.do_disconnect() self.client.do_disconnect()
self.assert_(self.client.socket.state == 'DISCONNECTED') self.assert_(self.client.socket.state == 'DISCONNECTED')
if __name__ == '__main__': if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(TestNonBlockingTCP) unittest.main()
unittest.TextTestRunner(verbosity=2).run(suite)
# vim: se ts=3: