#32437 closed Bug (fixed)
LiveServerTestCase.setUpClass() doesn't clean up fully on failure
Reported by: | Chris Jerdonek | Owned by: | Chris Jerdonek |
---|---|---|---|
Component: | Testing framework | Version: | 2.2 |
Severity: | Normal | Keywords: | LiveServerTestCase, setUpClass |
Cc: | Florian Apolloner, Tobias McNulty | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
While working on #32417, I noticed in this comment that LiveServerTestCase.setUpClass()
doesn't clean up all the way if setUpClass()
errors out.
Specifically, LiveServerTestCase.setUpClass()
looks like this:
@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()
doesn't undo the call to cls._live_server_modified_settings.enable()
.
I will post a PR shortly.
Change History (7)
comment:1 by , 4 years ago
Has patch: | set |
---|---|
Owner: | changed from | to
Status: | new → assigned |
comment:2 by , 4 years ago
Description: | modified (diff) |
---|
comment:3 by , 4 years ago
Cc: | added |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:5 by , 4 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Note:
See TracTickets
for help on using tickets.
The cleanup precedes the commit that modified the settings by three years (17e661641ddaf8266e7430d83cfb2039abc55df7 & 73a610d2a81bc3bf2d3834786b2458bc85953ed0) so it is more than likely that this was just an oversight at the time. I'll give the PR a review in a second.