nice-fy error reporting of self-tests
This commit is contained in:
parent
2458c139e4
commit
6e6b0ab5d9
|
@ -125,11 +125,14 @@ class HookRecorder:
|
||||||
py.test.fail("could not find %r check %r" % (name, check))
|
py.test.fail("could not find %r check %r" % (name, check))
|
||||||
|
|
||||||
def popcall(self, name):
|
def popcall(self, name):
|
||||||
|
__tracebackhide__ = True
|
||||||
for i, call in enumerate(self.calls):
|
for i, call in enumerate(self.calls):
|
||||||
if call._name == name:
|
if call._name == name:
|
||||||
del self.calls[i]
|
del self.calls[i]
|
||||||
return call
|
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):
|
def getcall(self, name):
|
||||||
l = self.getcalls(name)
|
l = self.getcalls(name)
|
||||||
|
|
|
@ -82,7 +82,7 @@ def test_hookrecorder_basic():
|
||||||
call = rec.popcall("pytest_xyz")
|
call = rec.popcall("pytest_xyz")
|
||||||
assert call.arg == 123
|
assert call.arg == 123
|
||||||
assert call._name == "pytest_xyz"
|
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():
|
def test_hookrecorder_basic_no_args_hook():
|
||||||
rec = HookRecorder(PluginManager())
|
rec = HookRecorder(PluginManager())
|
||||||
|
|
Loading…
Reference in New Issue