[py-svn] pytest commit f34cf98d4fc9: nice-fy error reporting of self-tests

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Tue Nov 23 15:45:33 CET 2010


# HG changeset patch -- Bitbucket.org
# Project pytest
# URL http://bitbucket.org/hpk42/pytest/overview
# User holger krekel <holger at merlinux.eu>
# Date 1290435618 -3600
# Node ID f34cf98d4fc9e2f326b0e946c4adf9c214ba569e
# Parent  286116561e6feec6e9ce0590f66558c12fb3b338
nice-fy error reporting of self-tests

--- a/testing/test_pytester.py
+++ b/testing/test_pytester.py
@@ -82,7 +82,7 @@ def test_hookrecorder_basic():
     call = rec.popcall("pytest_xyz")
     assert call.arg == 123
     assert call._name == "pytest_xyz"
-    pytest.raises(ValueError, "rec.popcall('abc')")
+    pytest.raises(pytest.fail.Exception, "rec.popcall('abc')")
 
 def test_hookrecorder_basic_no_args_hook():
     rec = HookRecorder(PluginManager())

--- a/_pytest/pytester.py
+++ b/_pytest/pytester.py
@@ -125,11 +125,14 @@ class HookRecorder:
                 py.test.fail("could not find %r check %r" % (name, check))
 
     def popcall(self, name):
+        __tracebackhide__ = True
         for i, call in enumerate(self.calls):
             if call._name == name:
                 del self.calls[i]
                 return call
-        raise ValueError("could not find call %r" %(name, ))
+        lines = ["could not find call %r, in:" % (name,)]
+        lines.extend(["  %s" % str(x) for x in self.calls])
+        py.test.fail("\n".join(lines))
 
     def getcall(self, name):
         l = self.getcalls(name)



More information about the pytest-commit mailing list