From 94c2fd4033d16365893f4571efbba64051488f32 Mon Sep 17 00:00:00 2001 From: antocuni Date: Wed, 6 Oct 2010 14:28:06 +0200 Subject: [PATCH] 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 --- py/_plugin/pytest_pdb.py | 5 +++-- testing/plugin/test_pytest_pdb.py | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/py/_plugin/pytest_pdb.py b/py/_plugin/pytest_pdb.py index f508e96f4..3f982dddf 100644 --- a/py/_plugin/pytest_pdb.py +++ b/py/_plugin/pytest_pdb.py @@ -2,7 +2,7 @@ interactive debugging with the Python Debugger. """ import py -import pdb, sys, linecache +import bdb, pdb, sys, linecache def pytest_addoption(parser): group = parser.getgroup("general") @@ -20,7 +20,8 @@ class PdbInvoke: session.config.option.tbstyle = "no" def pytest_runtest_makereport(self, item, call, __multicall__): 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 rep = __multicall__.execute() if "xfail" in rep.keywords: diff --git a/testing/plugin/test_pytest_pdb.py b/testing/plugin/test_pytest_pdb.py index f3cf001ab..0fbca26ef 100644 --- a/testing/plugin/test_pytest_pdb.py +++ b/testing/plugin/test_pytest_pdb.py @@ -39,6 +39,15 @@ class TestPDB: assert rep.skipped 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): p1 = testdir.makepyfile(""" def test_1():