[svn r57790] Reintroduce the --tb option. Add test.
--HG-- branch : trunk
This commit is contained in:
parent
d83db97806
commit
b52c58159f
|
@ -243,7 +243,8 @@ class ReprTraceback(Repr):
|
||||||
def toterminal(self, tw):
|
def toterminal(self, tw):
|
||||||
sepok = False
|
sepok = False
|
||||||
for entry in self.reprentries:
|
for entry in self.reprentries:
|
||||||
if sepok and self.style == "long":
|
if self.style == "long":
|
||||||
|
if sepok:
|
||||||
tw.sep(self.entrysep)
|
tw.sep(self.entrysep)
|
||||||
tw.line("")
|
tw.line("")
|
||||||
sepok = True
|
sepok = True
|
||||||
|
|
|
@ -268,7 +268,8 @@ class Node(object):
|
||||||
def _repr_failure_py(self, excinfo, outerr):
|
def _repr_failure_py(self, excinfo, outerr):
|
||||||
excinfo.traceback = self._prunetraceback(excinfo.traceback)
|
excinfo.traceback = self._prunetraceback(excinfo.traceback)
|
||||||
repr = excinfo.getrepr(funcargs=True,
|
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):
|
for secname, content in zip(["out", "err"], outerr):
|
||||||
if content:
|
if content:
|
||||||
repr.addsection("Captured std%s" % secname, content.rstrip())
|
repr.addsection("Captured std%s" % secname, content.rstrip())
|
||||||
|
|
|
@ -156,7 +156,7 @@ class TerminalReporter(BaseReporter):
|
||||||
#
|
#
|
||||||
|
|
||||||
def summary_failures(self):
|
def summary_failures(self):
|
||||||
if self._failed:
|
if self._failed and self.config.option.tbstyle != "no":
|
||||||
self.write_sep("=", "FAILURES")
|
self.write_sep("=", "FAILURES")
|
||||||
for ev in self._failed:
|
for ev in self._failed:
|
||||||
self.write_sep("_")
|
self.write_sep("_")
|
||||||
|
|
|
@ -161,3 +161,34 @@ class TestTerminal(InlineCollection):
|
||||||
"*waiting*",
|
"*waiting*",
|
||||||
"*%s*" % (modcol._config.topdir),
|
"*%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
|
||||||
|
|
Loading…
Reference in New Issue