fix a pdb problem when dropping to a "raises" related failure

--HG--
branch : trunk
This commit is contained in:
holger krekel 2010-02-08 14:17:01 +01:00
parent 3bca6be46d
commit c7326f1949
3 changed files with 23 additions and 1 deletions

View File

@ -29,6 +29,8 @@ Changes between 1.2.1 and 1.2.0
- fix issue63: assume <40 columns to be a bogus terminal width, default to 80
- fix pdb debugging to be in the correct frame on raises-related errors
- update apipkg.py to fix an issue where recursive imports might
unnecessarily break importing

View File

@ -91,10 +91,11 @@ class Pdb(py.std.pdb.Pdb):
stack, i = pdb.Pdb.get_stack(self, f, t)
if f is None:
i = max(0, len(stack) - 1)
while i and stack[i][0].f_locals.get("__tracebackhide__", False):
i-=1
return stack, i
def post_mortem(t):
# modified from pdb.py for the new get_stack() implementation
p = Pdb()
p.reset()
p.interaction(None, t)

View File

@ -43,3 +43,22 @@ class TestPDB:
child.expect("1 failed")
if child.isalive():
child.wait()
def test_pdb_interaction_exception(self, testdir):
p1 = testdir.makepyfile("""
import py
def globalfunc():
pass
def test_1():
py.test.raises(ValueError, globalfunc)
""")
child = testdir.spawn_pytest("--pdb %s" % p1)
child.expect(".*def test_1")
child.expect(".*py.test.raises.*globalfunc")
child.expect("(Pdb)")
child.sendline("globalfunc")
child.expect(".*function")
child.sendeof()
child.expect("1 failed")
if child.isalive():
child.wait()