Commit 7631b934 authored by Denis Bilenko's avatar Denis Bilenko

test__backdoor.py: do not leak the servers out of the test

parent 96a40e5f
......@@ -35,20 +35,26 @@ class Test(greentest.TestCase):
def test_quit(self):
server = backdoor.BackdoorServer(('127.0.0.1', 0))
server.start()
conn = socket.create_connection(('127.0.0.1', server.server_port))
read_until(conn, '>>> ')
conn.sendall('quit()\r\n')
line = conn.makefile().read()
self.assertEqual(line, '')
try:
conn = socket.create_connection(('127.0.0.1', server.server_port))
read_until(conn, '>>> ')
conn.sendall('quit()\r\n')
line = conn.makefile().read()
self.assertEqual(line, '')
finally:
server.stop()
def test_sys_exit(self):
server = backdoor.BackdoorServer(('127.0.0.1', 0))
server.start()
conn = socket.create_connection(('127.0.0.1', server.server_port))
read_until(conn, '>>> ')
conn.sendall('import sys; sys.exit(0)\r\n')
line = conn.makefile().read()
self.assertEqual(line, '')
try:
conn = socket.create_connection(('127.0.0.1', server.server_port))
read_until(conn, '>>> ')
conn.sendall('import sys; sys.exit(0)\r\n')
line = conn.makefile().read()
self.assertEqual(line, '')
finally:
server.stop()
if __name__ == '__main__':
......
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