#32417: LiveServerTestCase's tearDownClass() not symmetric with setUpClass()
--------------------------------+--------------------------------------
     Reporter:  Chris Jerdonek  |                    Owner:  nobody
         Type:  Uncategorized   |                   Status:  new
    Component:  Uncategorized   |                  Version:  2.2
     Severity:  Normal          |               Resolution:
     Keywords:                  |             Triage Stage:  Unreviewed
    Has patch:  0               |      Needs documentation:  0
  Needs tests:  0               |  Patch needs improvement:  0
Easy pickings:  0               |                    UI/UX:  0
--------------------------------+--------------------------------------

Comment (by Chris Jerdonek):

 After looking at this some more, rather than keeping the symmetry, it
 looks like the first three lines of
 `LiveServerTestCase._tearDownClassInternal` can simply be deleted:

 {{{#!python
 @classmethod
 def _tearDownClassInternal(cls):
     # There may not be a 'server_thread' attribute if setUpClass() for
 some
     # reasons has raised an exception.
     if hasattr(cls, 'server_thread'):
 }}}

 This is because it doesn't seem like it's possible for
 `_tearDownClassInternal()` to be called without `server_thread` being set.
 For example, per the [https://docs.python.org/3/library/unittest.html
 #setupclass-and-teardownclass Python unittest docs], `tearDownClass()`
 isn't called if `setUpClass()` errors out:

 > If an exception is raised during a setUpClass then the tests in the
 class are not run and the tearDownClass is not run.

 Also, `LiveServerTestCase.setUpClass()` only calls
 `_tearDownClassInternal()` when `cls.server_thread` is already set.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32417#comment:1>
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.f8e76a33adb48db32cae45a6075cd01a%40djangoproject.com.

Reply via email to