[py-svn] r51649 - in py/branch/event/py/test2: . testing
hpk at codespeak.net
hpk at codespeak.net
Tue Feb 19 19:05:18 CET 2008
Author: hpk
Date: Tue Feb 19 19:05:15 2008
New Revision: 51649
Modified:
py/branch/event/py/test2/collect.py
py/branch/event/py/test2/item.py
py/branch/event/py/test2/present.py
py/branch/event/py/test2/testing/test_present.py
Log:
* special generator test reporting
* repr_failure only on Function items
Modified: py/branch/event/py/test2/collect.py
==============================================================================
--- py/branch/event/py/test2/collect.py (original)
+++ py/branch/event/py/test2/collect.py Tue Feb 19 19:05:15 2008
@@ -25,7 +25,6 @@
"""
from __future__ import generators
import py
-from present import FuncPresenter
sysex = (KeyboardInterrupt, SystemExit, GeneratorExit)
@@ -450,12 +449,6 @@
if meth is not None:
return meth(self.obj)
- def repr_failure(self, excinfo):
- """ return a textual failure representation for this item. """
- p = FuncPresenter(self._config)
- p.repr_failure(self, excinfo)
- return p.stringio.getvalue()
-
class Generator(FunctionMixin, PyCollectorMixin, Collector):
def listdir(self):
self._prepare()
Modified: py/branch/event/py/test2/item.py
==============================================================================
--- py/branch/event/py/test2/item.py (original)
+++ py/branch/event/py/test2/item.py Tue Feb 19 19:05:15 2008
@@ -1,6 +1,7 @@
import py
from py.__.test2.collect import FunctionMixin, Base
+import present
_dummy = object()
@@ -64,3 +65,17 @@
""" execute the given test function. """
target(*args)
+ def repr_failure(self, excinfo):
+ """ return a textual failure representation for this item. """
+ p = present.FuncPresenter(self._config)
+ p.repr_failure_headline(self)
+ p.out.line("")
+ if self.name[-1] == "]": # generated test has trailing [num]
+ args = present.safe_repr._repr(self._args)
+ line = "%s%s -> %s%s" %(self.parent.name, self.name,
+ self.obj.__name__, args)
+ p.out.line(line)
+ p.repr_tb(self, excinfo)
+ return p.stringio.getvalue()
+
+
Modified: py/branch/event/py/test2/present.py
==============================================================================
--- py/branch/event/py/test2/present.py (original)
+++ py/branch/event/py/test2/present.py Tue Feb 19 19:05:15 2008
@@ -130,9 +130,12 @@
return traceback
def repr_failure(self, item, excinfo):
+ self.repr_failure_headline(item)
+ self.repr_tb(item, excinfo)
+
+ def repr_tb(self, item, excinfo):
traceback = self.filtertraceback(item, excinfo.traceback)
recursionindex = traceback.recursionindex()
-
repr_tb = getattr(self, "repr_tb_" + self.config.option.tbstyle)
repr_tb(item, excinfo, traceback, recursionindex)
@@ -147,12 +150,6 @@
last = traceback[-1]
first = traceback[0]
for index, entry in py.builtin.enumerate(traceback):
- if entry == first:
- if item:
- self.repr_failure_headline(item)
- self.out.line()
- else:
- self.out.line()
source = self.getentrysource(entry)
firstsourceline = entry.getfirstlinesource()
marker_location = entry.lineno - firstsourceline
Modified: py/branch/event/py/test2/testing/test_present.py
==============================================================================
--- py/branch/event/py/test2/testing/test_present.py (original)
+++ py/branch/event/py/test2/testing/test_present.py Tue Feb 19 19:05:15 2008
@@ -145,7 +145,6 @@
self.gentest(check, showlocals=True)
def test_repr_failing_generator(self):
- py.test.skip("XXX fix generator repr")
item, excinfo = suptest.getfailing("""
def test_gen():
def check(x):
@@ -153,9 +152,9 @@
yield check, 0
""")
s = item.repr_failure(excinfo)
+ print s
lines = s.split("\n")
- assert lines[1].find("test_gen[0] -> check(0)") != -1
- assert lines[2].find("def check(x):") != -1
- assert 0
+ assert lines[2].find("test_gen[0] -> check(0,)") != -1
+ assert lines[3].find("def check(x):") != -1
More information about the py-svn
mailing list