[py-svn] r35468 - in py/dist/py/test/rsession: . testing
fijal at codespeak.net
fijal at codespeak.net
Fri Dec 8 11:40:51 CET 2006
Author: fijal
Date: Fri Dec 8 11:40:49 2006
New Revision: 35468
Modified:
py/dist/py/test/rsession/rest.py
py/dist/py/test/rsession/testing/test_rest.py
Log:
Fixed --rest a bit, by adding links to tracebacks.
Modified: py/dist/py/test/rsession/rest.py
==============================================================================
--- py/dist/py/test/rsession/rest.py (original)
+++ py/dist/py/test/rsession/rest.py Fri Dec 8 11:40:49 2006
@@ -15,6 +15,7 @@
def __init__(self, *args, **kwargs):
super(RestReporter, self).__init__(*args, **kwargs)
self.rest = Rest()
+ self.traceback_num = 0
def get_linkwriter(self):
if self.linkwriter is None:
@@ -71,14 +72,14 @@
return root.fspath
def print_summary(self, total, skipped_str, failed_str):
+ self.skips()
+ self.failures()
+
txt = "%d tests run%s%s in %.2fs (rsync: %.2f)" % \
(total, skipped_str, failed_str, self.timeend - self.timestart,
self.timersync - self.timestart)
self.add_rest(Title(txt, belowchar='-'))
- self.skips()
- self.failures()
-
# since we're rendering each item, the links haven't been rendered
# yet
self.out.write(self.rest.render_links())
@@ -86,20 +87,22 @@
def report_ReceivedItemOutcome(self, event):
host = self.get_host(event)
if event.outcome.passed:
- status = "PASSED"
+ status = [Strong("PASSED")]
self.passed[host] += 1
elif event.outcome.skipped:
- status = "SKIPPED"
+ status = [Strong("SKIPPED")]
self.skipped_tests_outcome.append(event)
self.skipped[host] += 1
else:
- status = "FAILED"
+ status = [Strong("FAILED"),
+ InternalLink("traceback%d" % self.traceback_num)]
+ self.traceback_num += 1
self.failed[host] += 1
self.failed_tests_outcome.append(event)
# we'll take care of them later
itempath = self.get_path_from_item(event.item)
- self.add_rest(ListItem(Text("%10s:" % (host[:10],)), Strong(status),
- Text(itempath)))
+ status.append(Text(itempath))
+ self.add_rest(ListItem(Text("%10s:" % (host[:10],)), *status))
def skips(self):
# XXX hrmph, copied code
@@ -124,6 +127,7 @@
self.add_rest(ListItem('%s: %s' % (item, text)))
def failures(self):
+ self.traceback_num = 0
tbstyle = self.config.option.tbstyle
if self.failed_tests_outcome:
self.add_rest(Title('Exceptions:', belowchar='+'))
@@ -189,6 +193,8 @@
def repr_traceback(self, item, excinfo, traceback, style):
root = self.get_rootpath(item)
+ self.add_rest(LinkTarget('traceback%d' % self.traceback_num, ""))
+ self.traceback_num += 1
if style == 'long':
for entry in traceback:
link = self.get_linkwriter().get_link(root,
Modified: py/dist/py/test/rsession/testing/test_rest.py
==============================================================================
--- py/dist/py/test/rsession/testing/test_rest.py (original)
+++ py/dist/py/test/rsession/testing/test_rest.py Fri Dec 8 11:40:49 2006
@@ -123,7 +123,7 @@
event = Container(channel=False, outcome=outcome, item=item)
reporter.report_ReceivedItemOutcome(event)
assert stdout.getvalue() == """\
-* localhost\: **FAILED** foo.py/bar()/baz
+* localhost\: **FAILED** `traceback0`_ foo.py/bar()/baz
"""
@@ -184,13 +184,16 @@
]
reporter.config.option.tbstyle = 'no'
reporter.failures()
- assert stdout.getvalue() == """\
+ expected = """\
Exceptions\:
++++++++++++
foo/bar.py/baz() on localhost
+++++++++++++++++++++++++++++
+.. _`traceback0`:
+
+
FooError
++++++++
@@ -199,18 +202,22 @@
A foo has occurred
"""
+ assert stdout.getvalue() == expected
reporter.config.option.tbstyle = 'short'
stdout.seek(0)
stdout.truncate()
reporter.failures()
- assert stdout.getvalue() == """\
+ expected = """\
Exceptions\:
++++++++++++
foo/bar.py/baz() on localhost
+++++++++++++++++++++++++++++
+.. _`traceback0`:
+
+
::
foo/bar.py line 1
@@ -226,18 +233,22 @@
A foo has occurred
"""
+ assert stdout.getvalue() == expected
reporter.config.option.tbstyle = 'long'
stdout.seek(0)
stdout.truncate()
reporter.failures()
- stdout.getvalue() == """\
+ expected = """\
Exceptions\:
++++++++++++
foo/bar.py/baz() on localhost
+++++++++++++++++++++++++++++
+.. _`traceback0`:
+
+
+++++++++++++++++
foo/bar.py line 1
+++++++++++++++++
@@ -262,6 +273,8 @@
A foo has occurred
"""
+ assert stdout.getvalue() == expected
+
class TestRestReporter(AbstractTestReporter):
reporter = RestReporter
@@ -272,11 +285,11 @@
def test_report_received_item_outcome(self):
val = self.report_received_item_outcome()
expected = """\
-* localhost\: **FAILED** py/test/rsession/testing/test\_slave.py/funcpass
+* localhost\: **FAILED** `traceback0`_\n py/test/rsession/testing/test\_slave.py/funcpass
* localhost\: **SKIPPED** py/test/rsession/testing/test\_slave.py/funcpass
-* localhost\: **FAILED** py/test/rsession/testing/test\_slave.py/funcpass
+* localhost\: **FAILED** `traceback1`_\n py/test/rsession/testing/test\_slave.py/funcpass
* localhost\: **PASSED** py/test/rsession/testing/test\_slave.py/funcpass
More information about the pytest-commit
mailing list