Each LiveServerTestCase binds to a unique port or fails to start a server thread when run concurrently (#26011).
(self)
| 354 | |
| 355 | class LiveServerPort(LiveServerBase): |
| 356 | def test_port_bind(self): |
| 357 | """ |
| 358 | Each LiveServerTestCase binds to a unique port or fails to start a |
| 359 | server thread when run concurrently (#26011). |
| 360 | """ |
| 361 | TestCase = type("TestCase", (LiveServerBase,), {}) |
| 362 | try: |
| 363 | TestCase._start_server_thread() |
| 364 | except OSError as e: |
| 365 | if e.errno == errno.EADDRINUSE: |
| 366 | # We're out of ports, LiveServerTestCase correctly fails with |
| 367 | # an OSError. |
| 368 | return |
| 369 | # Unexpected error. |
| 370 | raise |
| 371 | try: |
| 372 | self.assertNotEqual( |
| 373 | self.live_server_url, |
| 374 | TestCase.live_server_url, |
| 375 | f"Acquired duplicate server addresses for server threads: " |
| 376 | f"{self.live_server_url}", |
| 377 | ) |
| 378 | finally: |
| 379 | TestCase.doClassCleanups() |
| 380 | |
| 381 | def test_specified_port_bind(self): |
| 382 | """LiveServerTestCase.port customizes the server's port.""" |
nothing calls this directly
no test coverage detected