mirror of https://github.com/django/django.git
Fixed thread termination in servers.tests.LiveServerPort on Python 3.10.9+, 3.11.1+, and 3.12+.
Class cleanups registered in TestCase subclasses are no longer called
as TestCase.doClassCleanups() only cleans up the particular class, see
c2102136be
This commit is contained in:
parent
4593bc5da1
commit
d02a9f0cee
|
@ -377,12 +377,15 @@ class LiveServerPort(LiveServerBase):
|
|||
return
|
||||
# Unexpected error.
|
||||
raise
|
||||
self.assertNotEqual(
|
||||
self.live_server_url,
|
||||
TestCase.live_server_url,
|
||||
f"Acquired duplicate server addresses for server threads: "
|
||||
f"{self.live_server_url}",
|
||||
)
|
||||
try:
|
||||
self.assertNotEqual(
|
||||
self.live_server_url,
|
||||
TestCase.live_server_url,
|
||||
f"Acquired duplicate server addresses for server threads: "
|
||||
f"{self.live_server_url}",
|
||||
)
|
||||
finally:
|
||||
TestCase.doClassCleanups()
|
||||
|
||||
def test_specified_port_bind(self):
|
||||
"""LiveServerTestCase.port customizes the server's port."""
|
||||
|
@ -393,12 +396,15 @@ class LiveServerPort(LiveServerBase):
|
|||
TestCase.port = s.getsockname()[1]
|
||||
s.close()
|
||||
TestCase._start_server_thread()
|
||||
self.assertEqual(
|
||||
TestCase.port,
|
||||
TestCase.server_thread.port,
|
||||
f"Did not use specified port for LiveServerTestCase thread: "
|
||||
f"{TestCase.port}",
|
||||
)
|
||||
try:
|
||||
self.assertEqual(
|
||||
TestCase.port,
|
||||
TestCase.server_thread.port,
|
||||
f"Did not use specified port for LiveServerTestCase thread: "
|
||||
f"{TestCase.port}",
|
||||
)
|
||||
finally:
|
||||
TestCase.doClassCleanups()
|
||||
|
||||
|
||||
class LiveServerThreadedTests(LiveServerBase):
|
||||
|
|
Loading…
Reference in New Issue