#27391: Support unittest.TestCase.debug() method
-------------------------------+-------------------------------------------
     Reporter:  Pavel          |      Owner:  nobody
  Savchenko                    |
         Type:  Uncategorized  |     Status:  new
    Component:  Uncategorized  |    Version:  1.10
     Severity:  Normal         |   Keywords:  unittest SimpleTestCase debug
 Triage Stage:  Unreviewed     |  Has patch:  0
Easy pickings:  0              |      UI/UX:  0
-------------------------------+-------------------------------------------
 == Introduction ==

 The documentation for
 [https://docs.python.org/2/library/unittest.html#unittest.TestCase.debug
 unittest.TestCase.debug] states that invoking it would:

   Run the test without collecting the result. This allows exceptions
 raised by the test to be propagated to the caller, and can be used to
 support running tests under a debugger.

 In essence, `debug()` invokes the test method same as
 [https://docs.python.org/2/library/unittest.html#unittest.TestCase.run
 TestCase.run()] does, without the added functionality of catching
 exceptions and related cruft.

 == Side effects ==

 A recent change in pytest (see references below) brought to our attention
 the fact that Django does not implement a `debug` method, and performs
 important stuff in `TestCase.__call__` (besides calling `run()`), such as
 calling `_pre_startup` and `_post_teardown` methods.

 Thus, since debug() is unimplemented, running debug on a django TestCase
 (for example for debugging purposes), results unintended behavior, such as
 certain methods not being called. Most importantly `_fixture_callback` and
 `_fixture_teardown` which also perform database rollback (or call
 `flush`).

 References:
 https://github.com/pytest-dev/pytest/pull/1890
 https://github.com/pytest-dev/pytest/issues/1932
 https://github.com/pytest-dev/pytest-django/pull/406
 https://github.com/python/cpython/blob/master/Lib/unittest/case.py#L651-L658

--
Ticket URL: <https://code.djangoproject.com/ticket/27391>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/052.c750974c71dcb0056b5724673eedbab0%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to