diff --git a/AUTHORS b/AUTHORS index 043de70c1..c74aa4af6 100644 --- a/AUTHORS +++ b/AUTHORS @@ -91,6 +91,7 @@ Martin Prusse Matt Bachmann Matt Williams Matthias Hafner +mbyt Michael Aquilina Michael Birtwell Michael Droettboom diff --git a/CHANGELOG.rst b/CHANGELOG.rst index a1aea9bbd..b02afe038 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -12,13 +12,20 @@ * Fix ``UnicodeEncodeError`` when string comparison with unicode has failed. (`#1864`_) Thanks `@AiOO`_ for the PR +* Do not call tearDown (and cleanups) when running unittest with ``--pdb`` + enabled. This allows proper post mortem debugging for all applications + which have significant logic in their tearDown method (`#1890`_). Thanks + `@mbyt`_ for the PR. + * .. _@joguSD: https://github.com/joguSD .. _@AiOO: https://github.com/AiOO +.. _@mbyt: https://github.com/mbyt .. _#1857: https://github.com/pytest-dev/pytest/issues/1857 .. _#1864: https://github.com/pytest-dev/pytest/issues/1864 +.. _#1890: https://github.com/pytest-dev/pytest/issues/1890 3.0.1 diff --git a/testing/test_pdb.py b/testing/test_pdb.py index 6e4f3e805..a0fbc473e 100644 --- a/testing/test_pdb.py +++ b/testing/test_pdb.py @@ -79,6 +79,25 @@ class TestPDB: if child.isalive(): child.wait() + def test_pdb_unittest_postmortem(self, testdir): + p1 = testdir.makepyfile(""" + import unittest + class Blub(unittest.TestCase): + def tearDown(self): + self.filename = None + def test_false(self): + self.filename = 'bla' + '.txt' + assert 0 + """) + child = testdir.spawn_pytest("--pdb %s" % p1) + child.expect('(Pdb)') + child.sendline('p self.filename') + child.sendeof() + rest = child.read().decode("utf8") + assert 'bla.txt' in rest + if child.isalive(): + child.wait() + def test_pdb_interaction_capture(self, testdir): p1 = testdir.makepyfile(""" def test_1():