Opened 5 years ago
Last modified 5 years ago
#32437 closed Bug
LiveServerTestCase.setUpClass() doesn't clean up fully on failure — at Initial Version
| Reported by: | Chris Jerdonek | Owned by: | nobody |
|---|---|---|---|
| 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
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}, ) ... 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 modify_settings().
I will post a PR shortly.
Note:
See TracTickets
for help on using tickets.