diff --git a/src/_pytest/unittest.py b/src/_pytest/unittest.py index 11dc77cc4ff..ac5ae628bc9 100644 --- a/src/_pytest/unittest.py +++ b/src/_pytest/unittest.py @@ -203,13 +203,7 @@ def _handle_skip(self): return False def runtest(self): - if self.config.pluginmanager.get_plugin("pdbinvoke") is None: - self._testcase(result=self) - else: - # disables tearDown and cleanups for post mortem debugging (see #1890) - if self._handle_skip(): - return - self._testcase.debug() + self._testcase(result=self) def _prunetraceback(self, excinfo): Function._prunetraceback(self, excinfo) diff --git a/testing/test_pdb.py b/testing/test_pdb.py index 3c56f40e1cb..b52313c8e5e 100644 --- a/testing/test_pdb.py +++ b/testing/test_pdb.py @@ -156,20 +156,31 @@ def test_pdb_unittest_postmortem(self, testdir): p1 = testdir.makepyfile( """ import unittest + + teardown_called = 0 + class Blub(unittest.TestCase): def tearDown(self): - self.filename = None - def test_false(self): + global teardown_called + teardown_called += 1 + + def test_error(self): self.filename = 'debug' + '.me' assert 0 + + def test_check(self): + assert teardown_called == 1 """ ) - child = testdir.spawn_pytest("--pdb %s" % p1) + child = testdir.spawn_pytest( + "--pdb {p1}::Blub::test_error {p1}::Blub::test_check".format(p1=p1) + ) child.expect("Pdb") child.sendline("p self.filename") - child.sendeof() + child.expect("'debug.me'") + child.sendline("c") rest = child.read().decode("utf8") - assert "debug.me" in rest + assert "= 1 failed, 1 passed in" in rest self.flush(child) def test_pdb_unittest_skip(self, testdir):