Join GitHub today
INTERNALERROR when raising exception from pytest_runtest_call() after failed tests #333
When raising an exception from pytest_runtest_call() after a test has been executed and failed, py.test crashes with an internal error.
If the test completed successfully, py.test works as expected and reports a test failure due to the exception in pytest_runtest_call().
I've attached a testcase. For me, the output is:
I am not sure what the best behavior in this case would be, but an internal error seems like the worst alternative :-).
Internal errors are to be expected when implementing hooks, and especially when using multicall.execute() so we don't consider this a bug, at least. (reporting could be nicer, maybe).
That being said, you could also improve your solution like this:
Thanks, that version works nicely enough for my usecase!
Generally, though, it seems to me that there really should be a way to make a test fail from a hook. If the problem is to distinguish between a true internal error, and an exception that was raised to make the test fail, maybe pytest could define a special exception type for that? E.g. if a hook raises