diff options
Diffstat (limited to 'tests/servers/tests.py')
| -rw-r--r-- | tests/servers/tests.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/servers/tests.py b/tests/servers/tests.py index cb91131607..e7b263c088 100644 --- a/tests/servers/tests.py +++ b/tests/servers/tests.py @@ -147,6 +147,24 @@ class LiveServerPort(LiveServerBase): if hasattr(TestCase, 'server_thread'): TestCase.server_thread.terminate() + def test_specified_port_bind(self): + """LiveServerTestCase.port customizes the server's port.""" + TestCase = type(str('TestCase'), (LiveServerBase,), {}) + # Find an open port and tell TestCase to use it. + s = socket.socket() + s.bind(('', 0)) + TestCase.port = s.getsockname()[1] + s.close() + TestCase.setUpClass() + try: + self.assertEqual( + TestCase.port, TestCase.server_thread.port, + 'Did not use specified port for LiveServerTestCase thread: %s' % TestCase.port + ) + finally: + if hasattr(TestCase, 'server_thread'): + TestCase.server_thread.terminate() + class LiverServerThreadedTests(LiveServerBase): """If LiverServerTestCase isn't threaded, these tests will hang.""" |
