Opened 4 years ago
Last modified 4 years ago
#32437 closed Bug
LiveServerTestCase.setUpClass() doesn't clean up fully on failure — at Version 2
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 (2)
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) |
---|
Note:
See TracTickets
for help on using tickets.