[py-svn] r61299 - in py/branch/pytestplugin/py/test: . plugin plugin/testing

hpk at codespeak.net hpk at codespeak.net
Sat Jan 24 13:44:44 CET 2009


Author: hpk
Date: Sat Jan 24 13:44:42 2009
New Revision: 61299

Modified:
   py/branch/pytestplugin/py/test/event.py
   py/branch/pytestplugin/py/test/plugin/pytest_resultlog.py
   py/branch/pytestplugin/py/test/plugin/pytest_terminal.py
   py/branch/pytestplugin/py/test/plugin/testing/test_terminal.py
Log:
unify skip/fail "longrepr" attribute of CollectionReports 


Modified: py/branch/pytestplugin/py/test/event.py
==============================================================================
--- py/branch/pytestplugin/py/test/event.py	(original)
+++ py/branch/pytestplugin/py/test/event.py	Sat Jan 24 13:44:42 2009
@@ -109,12 +109,11 @@
         else:
             self.when = when 
             self.outerr = outerr
+            self.longrepr = self.colitem._repr_failure_py(excinfo, outerr)
             if excinfo.errisinstance(Skipped):
                 self.skipped = True
                 self.reason = str(excinfo.value)
-                self.longrepr = excinfo._getreprcrash()
             else:
-                self.longrepr = self.colitem._repr_failure_py(excinfo, outerr)
                 self.failed = True
 
     def toterminal(self, out):

Modified: py/branch/pytestplugin/py/test/plugin/pytest_resultlog.py
==============================================================================
--- py/branch/pytestplugin/py/test/plugin/pytest_resultlog.py	(original)
+++ py/branch/pytestplugin/py/test/plugin/pytest_resultlog.py	Sat Jan 24 13:44:42 2009
@@ -66,7 +66,7 @@
                     code = "F"
                 elif ev.skipped: 
                     code = "S"
-            longrepr = str(ev.longrepr)
+            longrepr = str(ev.longrepr.reprcrash)
         else:
             assert isinstance(ev, ev.ItemTestReport)
             code = ev.outcome.shortrepr # XXX make independent from reporting 

Modified: py/branch/pytestplugin/py/test/plugin/pytest_terminal.py
==============================================================================
--- py/branch/pytestplugin/py/test/plugin/pytest_terminal.py	(original)
+++ py/branch/pytestplugin/py/test/plugin/pytest_terminal.py	Sat Jan 24 13:44:42 2009
@@ -76,9 +76,10 @@
         for event in self._skipped:
             if isinstance(event, event.CollectionReport):
                 longrepr = event.longrepr
+                entry = event.longrepr.reprcrash 
             else:
-                longrepr = event.outcome.longrepr
-            key = longrepr.path, longrepr.lineno, longrepr.message
+                entry = event.outcome.longrepr
+            key = entry.path, entry.lineno, entry.message
             d.setdefault(key, []).append(event)
         l = []
         for key, events in d.iteritems(): 
@@ -325,10 +326,8 @@
 
     def rep_CollectionReport(self, ev):
         super(CollectonlyReporter, self).rep_CollectionReport(ev)
-        if ev.failed:
+        if not ev.passed:
             self.outindent("!!! %s !!!" % ev.longrepr.reprcrash.message)
-        elif ev.skipped:
-            self.outindent("!!! %s !!!" % ev.longrepr.message)
         self.indent = self.indent[:-len(self.INDENT)]
 
     def rep_TestrunFinish(self, session):

Modified: py/branch/pytestplugin/py/test/plugin/testing/test_terminal.py
==============================================================================
--- py/branch/pytestplugin/py/test/plugin/testing/test_terminal.py	(original)
+++ py/branch/pytestplugin/py/test/plugin/testing/test_terminal.py	Sat Jan 24 13:44:42 2009
@@ -333,9 +333,10 @@
     def test_skip_reasons_folding(self):
         rep = BaseReporter()
         class longrepr:
-            path = 'xyz'
-            lineno = 3
-            message = "justso"
+            class reprcrash:
+                path = 'xyz'
+                lineno = 3
+                message = "justso"
 
         ev1 = event.CollectionReport(None, None)
         ev1.when = "execute"
@@ -343,7 +344,7 @@
         ev1.longrepr = longrepr 
         
         from py.__.test.runner import OutcomeRepr
-        out2 = OutcomeRepr(None, None, longrepr)
+        out2 = OutcomeRepr(None, None, longrepr.reprcrash)
         ev2 = event.ItemTestReport(None, skipped=out2)
         rep.processevent(ev1)
         rep.processevent(ev2)
@@ -352,9 +353,9 @@
         assert len(l) == 1
         num, fspath, lineno, reason = l[0]
         assert num == 2
-        assert fspath == longrepr.path
-        assert lineno == longrepr.lineno
-        assert reason == longrepr.message
+        assert fspath == longrepr.reprcrash.path
+        assert lineno == longrepr.reprcrash.lineno
+        assert reason == longrepr.reprcrash.message
 
 def test_repr_python_version():
     py.magic.patch(sys, 'version_info', (2, 5, 1, 'final', 0))



More information about the pytest-commit mailing list