This makes it possible to use asserts in helper functions (called from the test functions). E.g.
@pytest.mark.golden_test("test_add1/*.yml")
def test_add1(golden):
helper(add1(golden["input"]), golden.out["output"])
def helper(x, y):
assert x == y
This is useful if you have individual checks of a more complicated test case that you want to check between test functions.
Previously this was not possible because the stack frames were explicitly filtered to the one from the test function and two internal functions of this library.
Instead of an allow list I added a deny list to skip over functions calls that exist because pytest has rewritten the assertion. I'm not sure how stable this part it because we need to use the private _pytest. It will probably break if pytest changes something here. But I didn't find another way to get to that function.
I would appreciate more testing of this PR. I have only tested in my local project and the examples and tests in this repo.
This makes it possible to use
assert
s in helper functions (called from the test functions). E.g.This is useful if you have individual checks of a more complicated test case that you want to check between test functions.
Previously this was not possible because the stack frames were explicitly filtered to the one from the test function and two internal functions of this library.
Instead of an allow list I added a deny list to skip over functions calls that exist because pytest has rewritten the assertion. I'm not sure how stable this part it because we need to use the private
_pytest
. It will probably break if pytest changes something here. But I didn't find another way to get to that function.I would appreciate more testing of this PR. I have only tested in my local project and the examples and tests in this repo.