fix issue89 apply Daniel Nouri's patch to doctest/--pdb interaction.

This commit is contained in:
holger krekel 2011-11-15 13:28:22 +00:00
parent 9d3e51af9f
commit a51e52aee3
5 changed files with 30 additions and 2 deletions

View File

@ -22,3 +22,4 @@ Jan Balster
Grig Gheorghiu
Bob Ippolito
Christian Tismer
Daniel Nuri

View File

@ -14,6 +14,7 @@ Changes between 2.1.3 and XXX 2.2.0
- new feature to help optimizing the speed of your tests:
--durations=N option for displaying N slowest test calls
and setup/teardown methods.
- fix issue89: --pdb with unexpected exceptions in doctest work more sensibly
- fix and cleanup pytest's own test suite to not leak FDs
- fix issue83: link to generated funcarg list
- fix issue74: pyarg module names are now checked against imp.find_module false positives

View File

@ -70,7 +70,13 @@ class PdbInvoke:
tw.sep(">", "traceback")
rep.toterminal(tw)
tw.sep(">", "entering PDB")
post_mortem(call.excinfo._excinfo[2])
# A doctest.UnexpectedException is not useful for post_mortem.
# Use the underlying exception instead:
if isinstance(call.excinfo.value, py.std.doctest.UnexpectedException):
tb = call.excinfo.value.exc_info[2]
else:
tb = call.excinfo._excinfo[2]
post_mortem(tb)
rep._pdbshown = True
return rep

View File

@ -40,7 +40,7 @@ If you want to install or upgrade pytest you might just type::
most code probably "just" works because the hook was already called
for failing setup/teardown phases of a test.
Thanks to Ronny Pfannschmidt, David Burns, Jeff Donner XXX for their
Thanks to Ronny Pfannschmidt, David Burns, Jeff Donner, Daniel Nouri, XXX for their
help and feedback on various issues.
best,

View File

@ -106,6 +106,26 @@ class TestPDB:
if child.isalive():
child.wait()
def test_pdb_interaction_doctest(self, testdir):
p1 = testdir.makepyfile("""
import pytest
def function_1():
'''
>>> i = 0
>>> assert i == 1
'''
""")
child = testdir.spawn_pytest("--doctest-modules --pdb %s" % p1)
child.expect("(Pdb)")
child.sendline('i')
child.expect("0")
child.expect("(Pdb)")
child.sendeof()
rest = child.read()
assert "1 failed" in rest
if child.isalive():
child.wait()
def test_pdb_interaction_capturing_twice(self, testdir):
p1 = testdir.makepyfile("""
import pytest