mirror of
https://github.com/django/django.git
synced 2025-07-07 11:19:12 +00:00
[4.0.x] Fixed thread termination in servers.tests.LiveServerPort on Python < 3.10.9.
TestCase.doClassCleanups() cannot be called on Python < 3.10.9 because setUpClass()/tearDownClass() are called multiple times in LiveServerTestCase tests (refs #27079).
This commit is contained in:
parent
d065944353
commit
534895f1ac
@ -4,6 +4,7 @@ Tests for django.core.servers.
|
|||||||
import errno
|
import errno
|
||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
|
import sys
|
||||||
import threading
|
import threading
|
||||||
from http.client import HTTPConnection
|
from http.client import HTTPConnection
|
||||||
from urllib.error import HTTPError
|
from urllib.error import HTTPError
|
||||||
@ -364,7 +365,11 @@ class LiveServerPort(LiveServerBase):
|
|||||||
% self.live_server_url,
|
% self.live_server_url,
|
||||||
)
|
)
|
||||||
finally:
|
finally:
|
||||||
TestCase.doClassCleanups()
|
# Class cleanups registered in TestCase subclasses are no longer
|
||||||
|
# called as TestCase.doClassCleanups() only cleans up the
|
||||||
|
# particular class in Python 3.10.9+.
|
||||||
|
if sys.version_info >= (3, 10, 9):
|
||||||
|
TestCase.doClassCleanups()
|
||||||
TestCase.tearDownClass()
|
TestCase.tearDownClass()
|
||||||
|
|
||||||
def test_specified_port_bind(self):
|
def test_specified_port_bind(self):
|
||||||
@ -384,7 +389,11 @@ class LiveServerPort(LiveServerBase):
|
|||||||
% TestCase.port,
|
% TestCase.port,
|
||||||
)
|
)
|
||||||
finally:
|
finally:
|
||||||
TestCase.doClassCleanups()
|
# Class cleanups registered in TestCase subclasses are no longer
|
||||||
|
# called as TestCase.doClassCleanups() only cleans up the
|
||||||
|
# particular class in Python 3.10.9+.
|
||||||
|
if sys.version_info >= (3, 10, 9):
|
||||||
|
TestCase.doClassCleanups()
|
||||||
TestCase.tearDownClass()
|
TestCase.tearDownClass()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user