Skip to content

Commit 10b3274

Browse files
committed
adding corresponding test, authors and changelog
1 parent 4eeb475 commit 10b3274

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ Martin Prusse
9191
Matt Bachmann
9292
Matt Williams
9393
Matthias Hafner
94+
mbyt
9495
Michael Aquilina
9596
Michael Birtwell
9697
Michael Droettboom

CHANGELOG.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,20 @@
1212
* Fix ``UnicodeEncodeError`` when string comparison with unicode has failed. (`#1864`_)
1313
Thanks `@AiOO`_ for the PR
1414

15+
* Do not call tearDown (and cleanups) when running unittest with ``--pdb``
16+
enabled. This allows proper post mortem debugging for all applications
17+
which have significant logic in their tearDown method (`#1890`_). Thanks
18+
`@mbyt`_ for the PR.
19+
1520
*
1621

1722
.. _@joguSD: https://github.com/joguSD
1823
.. _@AiOO: https://github.com/AiOO
24+
.. _@mbyt: https://github.com/mbyt
1925

2026
.. _#1857: https://github.com/pytest-dev/pytest/issues/1857
2127
.. _#1864: https://github.com/pytest-dev/pytest/issues/1864
28+
.. _#1890: https://github.com/pytest-dev/pytest/issues/1890
2229

2330

2431
3.0.1

testing/test_pdb.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,25 @@ def test_1():
7979
if child.isalive():
8080
child.wait()
8181

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 = 'bla' + '.txt'
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 'bla.txt' in rest
98+
if child.isalive():
99+
child.wait()
100+
82101
def test_pdb_interaction_capture(self, testdir):
83102
p1 = testdir.makepyfile("""
84103
def test_1():

0 commit comments

Comments
 (0)