#33149: manage.py test --pdb does not open a debugger when a subtest fails
---------------------------------------------+------------------------
Reporter: Lucidiot | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: 3.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------------+------------------------
With a test case that contains a `TestCase.subTest` call, a failure or
error of a subtest does not cause pdb or ipdb to open when running
`manage.py test --pdb`.
{{{
#!python
from django.test import TestCase
class TestSomething(TestCase):
def test_something(self):
with self.subTest(a=1):
raise ZeroDivisionError("oh snap!")
}}}
{{{
λ ./manage.py test --pdb
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
...
======================================================================
ERROR: test_something (demo.app.tests.test_something.TestSomething) (a=1)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/.../tests/test_something.py", line 6, in test_something
raise ZeroDivisionError("oh snap!")
ZeroDivisionError: oh snap!
----------------------------------------------------------------------
Ran 1 tests in 0.154s
FAILED (errors=1)
Destroying test database for alias 'default'...
}}}
It seems that CPython has some
[https://github.com/python/cpython/blob/b0a6ede3d0bd6fa4ffe413ab4dfc1059201df25b/Lib/unittest/runner.py#L73
special handling code for subtest results] that does not use
`TestResult.addError` or `TestResult.addFailure`, and the `PDBDebugResult`
[https://github.com/django/django/blob/b263f4b69db4093847ccc3b85e51cc7f3759e42c/django/test/runner.py#L102-L108
only implements those]. Note that `--debug-sql` does work with subtests
because the `DebugSQLTextTestResult`
[https://github.com/django/django/blob/b263f4b69db4093847ccc3b85e51cc7f3759e42c/django/test/runner.py#L79-L84
supports subtests].
--
Ticket URL: <https://code.djangoproject.com/ticket/33149>
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/051.43f05f2c8d1841022802450f2a056384%40djangoproject.com.