[py-svn] py-trunk commit b6f591b81c20: fix --pdb to not drop interactive on xfailed tests
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Wed Jun 16 12:32:45 CEST 2010
# HG changeset patch -- Bitbucket.org
# Project py-trunk
# URL http://bitbucket.org/hpk42/py-trunk/overview
# User holger krekel <holger at merlinux.eu>
# Date 1276684508 -7200
# Node ID b6f591b81c20dd0cfdb743f79e07954fc8710ad3
# Parent f2e8fa33112789a60fbe700c01d7c3db08777499
fix --pdb to not drop interactive on xfailed tests
--- a/py/_plugin/pytest_pdb.py
+++ b/py/_plugin/pytest_pdb.py
@@ -15,19 +15,21 @@ def pytest_configure(config):
config.pluginmanager.register(PdbInvoke(), 'pdb')
class PdbInvoke:
- def pytest_runtest_makereport(self, item, call):
- if call.excinfo and not \
- call.excinfo.errisinstance(py.test.skip.Exception):
- # play well with capturing, slightly hackish
- capman = item.config.pluginmanager.getplugin('capturemanager')
- capman.suspendcapture()
-
- tw = py.io.TerminalWriter()
- repr = call.excinfo.getrepr()
- repr.toterminal(tw)
- post_mortem(call.excinfo._excinfo[2])
-
- capman.resumecapture_item(item)
+ def pytest_runtest_makereport(self, item, call, __multicall__):
+ if not call.excinfo or \
+ call.excinfo.errisinstance(py.test.skip.Exception):
+ return
+ rep = __multicall__.execute()
+ if "xfail" in rep.keywords:
+ return rep
+ # we assume that the above execute() suspended capturing
+ tw = py.io.TerminalWriter()
+ tw.line()
+ tw.sep(">", "traceback")
+ rep.toterminal(tw)
+ tw.sep(">", "entering PDB")
+ post_mortem(call.excinfo._excinfo[2])
+ return rep
class Pdb(py.std.pdb.Pdb):
def do_list(self, arg):
--- a/testing/plugin/test_pytest_pdb.py
+++ b/testing/plugin/test_pytest_pdb.py
@@ -20,6 +20,16 @@ class TestPDB:
tb = py.code.Traceback(pdblist[0][0])
assert tb[-1].name == "test_func"
+ def test_pdb_on_xfail(self, testdir, pdblist):
+ rep = testdir.inline_runsource1('--pdb', """
+ import py
+ @py.test.mark.xfail
+ def test_func():
+ assert 0
+ """)
+ assert "xfail" in rep.keywords
+ assert not pdblist
+
def test_pdb_on_skip(self, testdir, pdblist):
rep = testdir.inline_runsource1('--pdb', """
import py
--- a/py/_test/pluginmanager.py
+++ b/py/_test/pluginmanager.py
@@ -6,8 +6,8 @@ import inspect
from py._plugin import hookspec
default_plugins = (
- "default runner capture mark terminal skipping tmpdir monkeypatch "
- "recwarn pdb pastebin unittest helpconfig nose assertion genscript "
+ "default runner pdb capture mark terminal skipping tmpdir monkeypatch "
+ "recwarn pastebin unittest helpconfig nose assertion genscript "
"junitxml doctest").split()
def check_old_use(mod, modname):
--- a/testing/pip-reqs1.txt
+++ b/testing/pip-reqs1.txt
@@ -1,5 +1,4 @@
docutils
pygments
pexpect
-figleaf
hg+http://bitbucket.org/hpk42/execnet#egg=execnet
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -34,6 +34,7 @@ New features
Bug fixes / Maintenance
++++++++++++++++++++++++++
+- fix --pdb to ignore xfailed tests and unify its TB-reporting
- fix assertion interpretation with the ** operator
- fix issue105 assignment on the same line as a failing assertion
- fix issue104 proper escaping for test names in junitxml plugin
More information about the pytest-commit
mailing list