Updated tests

pull/12/merge
Sheng 2018-06-01 09:32:14 +08:00
parent cbeca1c377
commit babd9bd24f
2 changed files with 6 additions and 8 deletions

View File

@ -124,7 +124,7 @@ def run_ssh_server(port=2200, running=True):
continue continue
# wait for auth # wait for auth
chan = t.accept(20) chan = t.accept(2)
if chan is None: if chan is None:
print('*** No channel.') print('*** No channel.')
continue continue

View File

@ -17,7 +17,7 @@ handler.DELAY = 0.1
class TestApp(AsyncHTTPTestCase): class TestApp(AsyncHTTPTestCase):
_is_running = False running = [True]
sshserver_port = 2200 sshserver_port = 2200
body = u'hostname=127.0.0.1&port={}&username=robey&password=foo'.format(sshserver_port) # noqa body = u'hostname=127.0.0.1&port={}&username=robey&password=foo'.format(sshserver_port) # noqa
@ -32,19 +32,17 @@ class TestApp(AsyncHTTPTestCase):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
print('='*20)
t = threading.Thread( t = threading.Thread(
target=run_ssh_server, args=(cls.sshserver_port, cls) target=run_ssh_server, args=(cls.sshserver_port, cls.running)
) )
t.setDaemon(True) t.setDaemon(True)
t.start() t.start()
@classmethod @classmethod
def tearDownClass(cls): def tearDownClass(cls):
cls._is_running = True cls.running.pop()
print('='*20)
@classmethod
def __bool__(cls):
return cls._is_running
def test_app_with_invalid_form(self): def test_app_with_invalid_form(self):
response = self.fetch('/') response = self.fetch('/')