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())