﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
33149	Make --pdb work with subTest().	Lucidiot	Abhyudai	"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]."	Bug	closed	Testing framework	3.2	Normal	fixed			Accepted	1	0	0	0	0	0
