From 6e6b0ab5d9df01fbd327229ef2bdbcdb23490e1c Mon Sep 17 00:00:00 2001 From: holger krekel Date: Mon, 22 Nov 2010 15:20:18 +0100 Subject: [PATCH] nice-fy error reporting of self-tests --- _pytest/pytester.py | 5 ++++- testing/test_pytester.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/_pytest/pytester.py b/_pytest/pytester.py index 11ebc4472..ab4d75528 100644 --- 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) diff --git a/testing/test_pytester.py b/testing/test_pytester.py index 87878d734..8b246d7d1 100644 --- 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())