Commit 26811444 authored by Jason Madden's avatar Jason Madden

That just made things worse for no clear reason. Try some more tweaks.

parent 134f26bf
...@@ -27,12 +27,15 @@ class Test(greentest.TestCase): ...@@ -27,12 +27,15 @@ class Test(greentest.TestCase):
_server = None _server = None
def tearDown(self): def tearDown(self):
self._server.stop() if self._server is not None:
self._server.stop()
self.close_on_teardown.remove(self._server.stop)
self._server = None self._server = None
gevent.sleep() # let spawned greenlets die gevent.sleep() # let spawned greenlets die
super(Test, self).tearDown() super(Test, self).tearDown()
def _make_server(self, *args, **kwargs): def _make_server(self, *args, **kwargs):
assert self._server is None
self._server = backdoor.BackdoorServer(('127.0.0.1', 0), *args, **kwargs) self._server = backdoor.BackdoorServer(('127.0.0.1', 0), *args, **kwargs)
self._close_on_teardown(self._server.stop) self._close_on_teardown(self._server.stop)
self._server.start() self._server.start()
...@@ -43,8 +46,8 @@ class Test(greentest.TestCase): ...@@ -43,8 +46,8 @@ class Test(greentest.TestCase):
conn.connect(('127.0.0.1', self._server.server_port)) conn.connect(('127.0.0.1', self._server.server_port))
return conn return conn
def _close(self, conn): def _close(self, conn, cmd='quit()\r\n)'):
conn.sendall(b'quit()\r\n') conn.sendall(cmd)
line = readline(conn) line = readline(conn)
self.assertEqual(line, '') self.assertEqual(line, '')
conn.close() conn.close()
...@@ -77,9 +80,7 @@ class Test(greentest.TestCase): ...@@ -77,9 +80,7 @@ class Test(greentest.TestCase):
self._make_server() self._make_server()
conn = self._create_connection() conn = self._create_connection()
read_until(conn, b'>>> ') read_until(conn, b'>>> ')
conn.sendall(b'import sys; sys.exit(0)\r\n') self._close(conn, b'import sys; sys.exit(0)\r\n')
line = readline(conn)
self.assertEqual(line, '')
def test_banner(self): def test_banner(self):
banner = "Welcome stranger!" # native string banner = "Welcome stranger!" # native string
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment