File tree Expand file tree Collapse file tree 5 files changed +41
-1
lines changed Expand file tree Collapse file tree 5 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -91,6 +91,7 @@ Martin Prusse
91
91
Matt Bachmann
92
92
Matt Williams
93
93
Matthias Hafner
94
+ mbyt
94
95
Michael Aquilina
95
96
Michael Birtwell
96
97
Michael Droettboom
Original file line number Diff line number Diff line change 18
18
if a test suite uses ``pytest_plugins `` to load internal plugins (`#1888 `_).
19
19
Thanks `@jaraco `_ for the report and `@nicoddemus `_ for the PR (`#1891 `_).
20
20
21
+ * Do not call tearDown and cleanups when running tests from
22
+ ``unittest.TestCase `` subclasses with ``--pdb ``
23
+ enabled. This allows proper post mortem debugging for all applications
24
+ which have significant logic in their tearDown machinery (`#1890 `_). Thanks
25
+ `@mbyt `_ for the PR.
26
+
21
27
*
22
28
23
29
.. _@joguSD : https://github.com/joguSD
24
30
.. _@AiOO : https://github.com/AiOO
31
+ .. _@mbyt : https://github.com/mbyt
25
32
26
33
.. _#1857 : https://github.com/pytest-dev/pytest/issues/1857
27
34
.. _#1864 : https://github.com/pytest-dev/pytest/issues/1864
28
35
.. _#1888 : https://github.com/pytest-dev/pytest/issues/1888
29
36
.. _#1891 : https://github.com/pytest-dev/pytest/pull/1891
37
+ .. _#1890 : https://github.com/pytest-dev/pytest/issues/1890
30
38
31
39
32
40
3.0.1
Original file line number Diff line number Diff line change @@ -150,7 +150,12 @@ def stopTest(self, testcase):
150
150
pass
151
151
152
152
def runtest (self ):
153
- self ._testcase (result = self )
153
+ if self .config .pluginmanager .get_plugin ("pdbinvoke" ) is None :
154
+ self ._testcase (result = self )
155
+ else :
156
+ # disables tearDown and cleanups for post mortem debugging (see #1890)
157
+ self ._testcase .debug ()
158
+
154
159
155
160
def _prunetraceback (self , excinfo ):
156
161
pytest .Function ._prunetraceback (self , excinfo )
Original file line number Diff line number Diff line change @@ -33,6 +33,13 @@ distributing tests to multiple CPUs via the ``-nNUM`` option if you
33
33
installed the ``pytest-xdist `` plugin. Please refer to
34
34
the general ``pytest `` documentation for many more examples.
35
35
36
+ .. note ::
37
+
38
+ Running tests from ``unittest.TestCase `` subclasses with ``--pdb `` will
39
+ disable tearDown and cleanup methods for the case that an Exception
40
+ occurs. This allows proper post mortem debugging for all applications
41
+ which have significant logic in their tearDown machinery.
42
+
36
43
Mixing pytest fixtures into unittest.TestCase style tests
37
44
-----------------------------------------------------------
38
45
Original file line number Diff line number Diff line change @@ -79,6 +79,25 @@ def test_1():
79
79
if child .isalive ():
80
80
child .wait ()
81
81
82
+ def test_pdb_unittest_postmortem (self , testdir ):
83
+ p1 = testdir .makepyfile ("""
84
+ import unittest
85
+ class Blub(unittest.TestCase):
86
+ def tearDown(self):
87
+ self.filename = None
88
+ def test_false(self):
89
+ self.filename = 'debug' + '.me'
90
+ assert 0
91
+ """ )
92
+ child = testdir .spawn_pytest ("--pdb %s" % p1 )
93
+ child .expect ('(Pdb)' )
94
+ child .sendline ('p self.filename' )
95
+ child .sendeof ()
96
+ rest = child .read ().decode ("utf8" )
97
+ assert 'debug.me' in rest
98
+ if child .isalive ():
99
+ child .wait ()
100
+
82
101
def test_pdb_interaction_capture (self , testdir ):
83
102
p1 = testdir .makepyfile ("""
84
103
def test_1():
You can’t perform that action at this time.
0 commit comments