Skip to content

xfail behaving more like skip #7060

Closed
Closed
@mentaal

Description

@mentaal

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: questiongeneral question, might be closed after 2 weeks of inactivity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions