Anonymous committed 21ed6e8

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

  • Participants
  • Parent commits 94835d0

Comments (0)

Files changed (2)


 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")
         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):
         rep = __multicall__.execute()
         if "xfail" in rep.keywords:


         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():