summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Jerdonek <chris.jerdonek@gmail.com>2021-02-12 12:10:42 -0800
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-02-15 10:25:11 +0100
commit600ff26a85752071da36e3a94c66dd8a77ee314a (patch)
tree7a85bb1c85a4c9ba017ed4739790435f4f3a00a7
parentfc0069bfa52f9d8bd62aa0f5749905d767ab42e9 (diff)
Fixed #32417 -- Removed unneeded hasattr() check in LiveServerTestCase._tearDownClassInternal().
-rw-r--r--django/test/testcases.py18
1 files changed, 7 insertions, 11 deletions
diff --git a/django/test/testcases.py b/django/test/testcases.py
index dfa4f41fb5..5c8a46b153 100644
--- a/django/test/testcases.py
+++ b/django/test/testcases.py
@@ -1563,18 +1563,14 @@ class LiveServerTestCase(TransactionTestCase):
@classmethod
def _tearDownClassInternal(cls):
- # There may not be a 'server_thread' attribute if setUpClass() for some
- # reasons has raised an exception.
- if hasattr(cls, 'server_thread'):
- # Terminate the live server's thread
- cls.server_thread.terminate()
+ # Terminate the live server's thread.
+ cls.server_thread.terminate()
+ # Restore sqlite in-memory database connections' non-shareability.
+ for conn in cls.server_thread.connections_override.values():
+ conn.dec_thread_sharing()
- # Restore sqlite in-memory database connections' non-shareability.
- for conn in cls.server_thread.connections_override.values():
- conn.dec_thread_sharing()
-
- cls._live_server_modified_settings.disable()
- super().tearDownClass()
+ cls._live_server_modified_settings.disable()
+ super().tearDownClass()
@classmethod
def tearDownClass(cls):