File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818 if a test suite uses ``pytest_plugins `` to load internal plugins (`#1888 `_).
1919 Thanks `@jaraco `_ for the report and `@nicoddemus `_ for the PR (`#1891 `_).
2020
21- * Do not call tearDown (and cleanups) when running unittest with ``--pdb ``
21+ * Do not call tearDown and cleanups when running tests from
22+ ``unittest.TestCase `` subclasses with ``--pdb ``
2223 enabled. This allows proper post mortem debugging for all applications
23- which have significant logic in their tearDown method (`#1890 `_). Thanks
24+ which have significant logic in their tearDown machinery (`#1890 `_). Thanks
2425 `@mbyt `_ for the PR.
2526
2627*
Original file line number Diff line number Diff line change @@ -153,7 +153,7 @@ def runtest(self):
153153 if self .config .pluginmanager .get_plugin ("pdbinvoke" ) is None :
154154 self ._testcase (result = self )
155155 else :
156- # disables tearDown and cleanups for post mortem debugging
156+ # disables tearDown and cleanups for post mortem debugging (see #1890)
157157 self ._testcase .debug ()
158158
159159
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
3333installed the ``pytest-xdist `` plugin. Please refer to
3434the general ``pytest `` documentation for many more examples.
3535
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 is
40+ occurs. This allows proper post mortem debugging for all applications
41+ which have significant logic in their tearDown machinery.
42+
3643Mixing pytest fixtures into unittest.TestCase style tests
3744-----------------------------------------------------------
3845
Original file line number Diff line number Diff line change @@ -86,15 +86,15 @@ class Blub(unittest.TestCase):
8686 def tearDown(self):
8787 self.filename = None
8888 def test_false(self):
89- self.filename = 'bla ' + '.txt '
89+ self.filename = 'debug ' + '.me '
9090 assert 0
9191 """ )
9292 child = testdir .spawn_pytest ("--pdb %s" % p1 )
9393 child .expect ('(Pdb)' )
9494 child .sendline ('p self.filename' )
9595 child .sendeof ()
9696 rest = child .read ().decode ("utf8" )
97- assert 'bla.txt ' in rest
97+ assert 'debug.me ' in rest
9898 if child .isalive ():
9999 child .wait ()
100100
You can’t perform that action at this time.
0 commit comments