#32437: LiveServerTestCase.setUpClass() doesn't clean up fully on failure
-------------------------------------+-------------------------------------
               Reporter:  Chris      |          Owner:  nobody
  Jerdonek                           |
                   Type:  Bug        |         Status:  new
              Component:  Testing    |        Version:  2.2
  framework                          |       Keywords:
               Severity:  Normal     |  LiveServerTestCase,setUpClass
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 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},
     )
     ...
     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 `modify_settings()`.

 I will post a PR shortly.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32437>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/052.6a48b2727f155921fab30f2ba435eef3%40djangoproject.com.

Reply via email to