fix the annoying interaction between "pdb.set_trace()" and --pdb. The problem

is that pdb raises BdbQuit on exit, which is then caught by --pdb, showing an
unwanted pdb prompt.  Fix it by making --pdb to ignore BdbQuit

--HG--
branch : trunk
This commit is contained in:
antocuni 2010-10-06 14:28:06 +02:00
parent fe54762b93
commit 94c2fd4033
2 changed files with 12 additions and 2 deletions

View File

@ -2,7 +2,7 @@
interactive debugging with the Python Debugger. interactive debugging with the Python Debugger.
""" """
import py import py
import pdb, sys, linecache import bdb, pdb, sys, linecache
def pytest_addoption(parser): def pytest_addoption(parser):
group = parser.getgroup("general") group = parser.getgroup("general")
@ -20,7 +20,8 @@ class PdbInvoke:
session.config.option.tbstyle = "no" session.config.option.tbstyle = "no"
def pytest_runtest_makereport(self, item, call, __multicall__): def pytest_runtest_makereport(self, item, call, __multicall__):
if not call.excinfo or \ if not call.excinfo or \
call.excinfo.errisinstance(py.test.skip.Exception): call.excinfo.errisinstance(py.test.skip.Exception) or \
call.excinfo.errisinstance(bdb.BdbQuit):
return return
rep = __multicall__.execute() rep = __multicall__.execute()
if "xfail" in rep.keywords: if "xfail" in rep.keywords:

View File

@ -39,6 +39,15 @@ class TestPDB:
assert rep.skipped assert rep.skipped
assert len(pdblist) == 0 assert len(pdblist) == 0
def test_pdb_on_BdbQuit(self, testdir, pdblist):
rep = testdir.inline_runsource1('--pdb', """
import py, bdb
def test_func():
raise bdb.BdbQuit
""")
assert rep.failed
assert len(pdblist) == 0
def test_pdb_interaction(self, testdir): def test_pdb_interaction(self, testdir):
p1 = testdir.makepyfile(""" p1 = testdir.makepyfile("""
def test_1(): def test_1():