Closed
Description
Hi there,
In the docs for xfail it says:
def test_function2():
import slow_module
if slow_module.slow_function():
pytest.xfail("slow_module taking too long")
These two examples illustrate situations where you don’t want to check for a condition at the module level, which is when a condition would otherwise be evaluated for marks.
This will make test_function XFAIL. Note that no other code is executed after the pytest.xfail call, differently from the marker. That’s because it is implemented internally by raising a known exception.
The behavior describes doesn't really sound like xfail to me. It's more like skip. The testcase isn't run. If I put the pytest.xfail call at the end of the test, an exception will be thrown before I get to it.
Am I misunderstanding. What's the intended usage for this?
The reason what I want a dynamic xfail is because I have to read information during the test and use that to determine if the test can be marked as xfail.
Thank you