diff --git a/CHANGELOG b/CHANGELOG index f646e7502..7ae0fb80e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -13,6 +13,7 @@ Changes between 1.3.4 and 2.0.0dev0 is removed). - add a new "-q" option which decreases verbosity and prints a more nose/unittest-style "dot" output. +- fix issue135 - marks now work with unittest test cases as well - fix issue126 - introduce py.test.set_trace() to trace execution via PDB during the running of tests even if capturing is ongoing. - fix issue123 - new "python -m py.test" invocation for py.test diff --git a/_pytest/pdb.py b/_pytest/pdb.py index 04fe82f68..cb870a1c0 100644 --- a/_pytest/pdb.py +++ b/_pytest/pdb.py @@ -42,10 +42,6 @@ def pytest_runtest_makereport(): pytestPDB.item = None class PdbInvoke: - def pytest_sessionfinish(self, session): - # don't display failures again at the end - session.config.option.tbstyle = "no" - @pytest.mark.tryfirst def pytest_runtest_makereport(self, item, call, __multicall__): if not call.excinfo or \ @@ -62,6 +58,7 @@ class PdbInvoke: rep.toterminal(tw) tw.sep(">", "entering PDB") post_mortem(call.excinfo._excinfo[2]) + rep._pdbshown = True return rep def post_mortem(t): diff --git a/_pytest/runner.py b/_pytest/runner.py index 5002ba7ae..08cdc96f3 100644 --- a/_pytest/runner.py +++ b/_pytest/runner.py @@ -358,7 +358,9 @@ def skip(msg=""): skip.Exception = Skipped def fail(msg="", pytrace=True): - """ explicitely fail an currently-executing test with the given Message. """ + """ explicitely fail an currently-executing test with the given Message. + if @pytrace is not True the msg represents the full failure information. + """ __tracebackhide__ = True raise Failed(msg=msg, pytrace=pytrace) fail.Exception = Failed diff --git a/_pytest/terminal.py b/_pytest/terminal.py index 05b07091f..a29ad0c5d 100644 --- a/_pytest/terminal.py +++ b/_pytest/terminal.py @@ -332,13 +332,21 @@ class TerminalReporter: # # summaries for sessionfinish # + def getreports(self, name): + l = [] + for x in self.stats.get(name, []): + if not hasattr(x, '_pdbshown'): + l.append(x) + return l def summary_failures(self): - tbstyle = self.config.option.tbstyle - if 'failed' in self.stats and tbstyle != "no": + if self.config.option.tbstyle != "no": + reports = self.getreports('failed') + if not reports: + return self.write_sep("=", "FAILURES") - for rep in self.stats['failed']: - if tbstyle == "line": + for rep in reports: + if self.config.option.tbstyle == "line": line = self._getcrashline(rep) self.write_line(line) else: @@ -347,7 +355,10 @@ class TerminalReporter: rep.toterminal(self._tw) def summary_errors(self): - if 'error' in self.stats and self.config.option.tbstyle != "no": + if self.config.option.tbstyle != "no": + reports = self.getreports('error') + if not reports: + return self.write_sep("=", "ERRORS") for rep in self.stats['error']: msg = self._getfailureheadline(rep) diff --git a/pytest.py b/pytest.py index e553791b7..517b957f7 100644 --- a/pytest.py +++ b/pytest.py @@ -5,7 +5,7 @@ see http://pytest.org for documentation and details (c) Holger Krekel and others, 2004-2010 """ -__version__ = '2.0.0.dev32' +__version__ = '2.0.0.dev33' __all__ = ['main'] from _pytest.core import main, UsageError, _preloadplugins diff --git a/setup.py b/setup.py index c7b62fe70..be0ba2e42 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ def main(): name='pytest', description='py.test: simple powerful testing with Python', long_description = long_description, - version='2.0.0.dev32', + version='2.0.0.dev33', url='http://pytest.org', license='MIT license', platforms=['unix', 'linux', 'osx', 'cygwin', 'win32'], diff --git a/testing/test_pdb.py b/testing/test_pdb.py index 5614a1371..9b9c5df4c 100644 --- a/testing/test_pdb.py +++ b/testing/test_pdb.py @@ -143,3 +143,11 @@ class TestPDB: child.expect("x = 5") child.sendeof() child.wait() + + def test_pdb_collection_failure_is_shown(self, testdir): + p1 = testdir.makepyfile("""xxx """) + result = testdir.runpytest("--pdb", p1) + result.stdout.fnmatch_lines([ + "*NameError*xxx*", + "*1 error*", + ])