MCPcopy
hub / github.com/django/django / test_port_bind

Method test_port_bind

tests/servers/tests.py:356–379  ·  view source on GitHub ↗

Each LiveServerTestCase binds to a unique port or fails to start a server thread when run concurrently (#26011).

(self)

Source from the content-addressed store, hash-verified

354
355class 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."""

Callers

nothing calls this directly

Calls 1

_start_server_threadMethod · 0.80

Tested by

no test coverage detected