closes #67 new super-short traceback-printing option: "--tb=line" will print a single line for each failing (python) test indicating its filename, lineno and the failure value

--HG--
branch : trunk
This commit is contained in:
holger krekel
2010-01-27 12:52:19 +01:00
parent b18ab6e03b
commit 98608611af
3 changed files with 40 additions and 11 deletions

View File

@@ -18,8 +18,8 @@ def pytest_addoption(parser):
help="show more info, valid: skipped,xfailed")
group._addoption('--tb', metavar="style",
action="store", dest="tbstyle", default='long',
type="choice", choices=['long', 'short', 'no'],
help="traceback verboseness (long/short/no).")
type="choice", choices=['long', 'short', 'no', 'line'],
help="traceback print mode (long/short/line/no).")
group._addoption('--fulltrace',
action="store_true", dest="fulltrace", default=False,
help="don't cut any tracebacks (default is to cut).")
@@ -272,15 +272,18 @@ class TerminalReporter:
if failreports:
self.write_sep("#", "LOOPONFAILING", red=True)
for report in failreports:
try:
loc = report.longrepr.reprcrash
except AttributeError:
loc = str(report.longrepr)[:50]
loc = self._getcrashline(report)
self.write_line(loc, red=True)
self.write_sep("#", "waiting for changes")
for rootdir in rootdirs:
self.write_line("### Watching: %s" %(rootdir,), bold=True)
def _getcrashline(self, report):
try:
return report.longrepr.reprcrash
except AttributeError:
return str(report.longrepr)[:50]
def _reportinfoline(self, item):
collect_fspath = self._getfspath(item)
fspath, lineno, msg = self._getreportinfo(item)
@@ -333,13 +336,18 @@ class TerminalReporter:
#
def summary_failures(self):
if 'failed' in self.stats and self.config.option.tbstyle != "no":
tbstyle = self.config.getvalue("tbstyle")
if 'failed' in self.stats and tbstyle != "no":
self.write_sep("=", "FAILURES")
for rep in self.stats['failed']:
msg = self._getfailureheadline(rep)
self.write_sep("_", msg)
self.write_platinfo(rep)
rep.toterminal(self._tw)
if tbstyle == "line":
line = self._getcrashline(rep)
self.write_line(line)
else:
msg = self._getfailureheadline(rep)
self.write_sep("_", msg)
self.write_platinfo(rep)
rep.toterminal(self._tw)
def summary_errors(self):
if 'error' in self.stats and self.config.option.tbstyle != "no":