﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
32437	LiveServerTestCase.setUpClass() doesn't clean up fully on failure	Chris Jerdonek	Chris Jerdonek	"While working on #32417, I noticed in [https://code.djangoproject.com/ticket/32417#comment:6 this comment] that `LiveServerTestCase.setUpClass()` doesn't clean up all the way if `setUpClass()` errors out.

Specifically, `LiveServerTestCase.setUpClass()` [https://github.com/django/django/blob/0963f184abd96800b76b19a6a181e1b544c7fafe/django/test/testcases.py#L1543-L1547 looks like] this:

{{{#!python
@classmethod
def setUpClass(cls):
    super().setUpClass()
    ...
    cls._live_server_modified_settings = modify_settings(
        ALLOWED_HOSTS={'append': cls.allowed_host},
    )
    cls._live_server_modified_settings.enable()
    ...
    if cls.server_thread.error:
        # Clean up behind ourselves, since tearDownClass won't get called in
        # case of errors.
        cls._tearDownClassInternal()
        raise cls.server_thread.error
}}}

But `_tearDownClassInternal()` [https://github.com/django/django/blob/0963f184abd96800b76b19a6a181e1b544c7fafe/django/test/testcases.py#L1559-L1568 doesn't undo] the call to `cls._live_server_modified_settings.enable()`.

I will post a PR shortly.
"	Bug	closed	Testing framework	2.2	Normal	fixed	LiveServerTestCase,setUpClass	Florian Apolloner Tobias McNulty	Ready for checkin	1	0	0	0	0	0
