diff --git a/CHANGELOG b/CHANGELOG index a982210b0..7155d70fd 100644 --- 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 diff --git a/py/_plugin/pytest_pdb.py b/py/_plugin/pytest_pdb.py index f8b69f799..a08318d92 100644 --- 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): diff --git a/py/_test/pluginmanager.py b/py/_test/pluginmanager.py index d1b673421..3d5377467 100644 --- 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): diff --git a/testing/pip-reqs1.txt b/testing/pip-reqs1.txt index 376a9a6bd..09023a38d 100644 --- 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 diff --git a/testing/plugin/test_pytest_pdb.py b/testing/plugin/test_pytest_pdb.py index dfc1c9955..8a9f07ce2 100644 --- 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