[py-svn] r57790 - in py/trunk/py: code test test/report test/report/testing
arigo at codespeak.net
arigo at codespeak.net
Wed Sep 3 10:15:46 CEST 2008
Author: arigo
Date: Wed Sep 3 10:15:44 2008
New Revision: 57790
Modified:
py/trunk/py/code/excinfo.py
py/trunk/py/test/collect.py
py/trunk/py/test/report/terminal.py
py/trunk/py/test/report/testing/test_terminal.py
Log:
Reintroduce the --tb option. Add test.
Modified: py/trunk/py/code/excinfo.py
==============================================================================
--- py/trunk/py/code/excinfo.py (original)
+++ py/trunk/py/code/excinfo.py Wed Sep 3 10:15:44 2008
@@ -243,9 +243,10 @@
def toterminal(self, tw):
sepok = False
for entry in self.reprentries:
- if sepok and self.style == "long":
- tw.sep(self.entrysep)
- tw.line("")
+ if self.style == "long":
+ if sepok:
+ tw.sep(self.entrysep)
+ tw.line("")
sepok = True
entry.toterminal(tw)
if self.extraline:
Modified: py/trunk/py/test/collect.py
==============================================================================
--- py/trunk/py/test/collect.py (original)
+++ py/trunk/py/test/collect.py Wed Sep 3 10:15:44 2008
@@ -268,7 +268,8 @@
def _repr_failure_py(self, excinfo, outerr):
excinfo.traceback = self._prunetraceback(excinfo.traceback)
repr = excinfo.getrepr(funcargs=True,
- showlocals=self._config.option.showlocals)
+ showlocals=self._config.option.showlocals,
+ style=self._config.option.tbstyle)
for secname, content in zip(["out", "err"], outerr):
if content:
repr.addsection("Captured std%s" % secname, content.rstrip())
Modified: py/trunk/py/test/report/terminal.py
==============================================================================
--- py/trunk/py/test/report/terminal.py (original)
+++ py/trunk/py/test/report/terminal.py Wed Sep 3 10:15:44 2008
@@ -156,7 +156,7 @@
#
def summary_failures(self):
- if self._failed:
+ if self._failed and self.config.option.tbstyle != "no":
self.write_sep("=", "FAILURES")
for ev in self._failed:
self.write_sep("_")
Modified: py/trunk/py/test/report/testing/test_terminal.py
==============================================================================
--- py/trunk/py/test/report/testing/test_terminal.py (original)
+++ py/trunk/py/test/report/testing/test_terminal.py Wed Sep 3 10:15:44 2008
@@ -161,3 +161,34 @@
"*waiting*",
"*%s*" % (modcol._config.topdir),
])
+
+ def test_tb_option(self):
+ for tbopt in ["no", "short", "long"]:
+ print 'testing --tb=%s...' % tbopt
+ modcol = self.getmodulecol("""
+ import py
+ def g():
+ raise IndexError
+ def test_func():
+ print 6*7
+ g() # --calling--
+ """, configargs=("--tb=%s" % tbopt,), withsession=True)
+ stringio = py.std.cStringIO.StringIO()
+ rep = TerminalReporter(modcol._config, file=stringio)
+ rep.processevent(event.TestrunStart())
+ for item in self.session.genitems([modcol]):
+ ev = basic_run_report(item)
+ rep.processevent(ev)
+ rep.processevent(event.TestrunFinish())
+ s = popvalue(stringio)
+ if tbopt == "long":
+ assert 'print 6*7' in s
+ else:
+ assert 'print 6*7' not in s
+ if tbopt != "no":
+ assert '--calling--' in s
+ assert 'IndexError' in s
+ else:
+ assert 'FAILURES' not in s
+ assert '--calling--' not in s
+ assert 'IndexError' not in s
More information about the pytest-commit
mailing list