-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pytest.xfail
and pytest.skip
as context managers
#13001
Comments
That's something to put into subtests |
Learned something new today! It looks like |
...huh, that seems backwards to me? Your original proposal is limited by that, but e.g. using parametrize isn't: @pytest.mark.parametrize("inp, out", [
("hello", "hello"),
pytest.param(
"World", "WORLD",
marks=[pytest.mark.xfail("external/matcher#123: match doesn't support case-insensitive matching yet")],
),
])
def test_match(inp, out):
assert match(inp, out) |
@The-Compiler i believe the problem mentioned is that we cannot mark a subtest as xfail a parameterized test can get marks via the id cc @nicoddemus for pytest-subtests |
What's the problem this feature will solve?
For some reason we may expect a specific part of the test to fail or to be skipped (maybe conditionally), usually because there's a blocking issue to be resolved.
Describe the solution you'd like
We propose exposing
pytest.xfail
andpytest.skip
(or their equivalents) as context managers, just likepytest.raises
. So we may have:pytest.skip
is used for a similar purpose, only when the broken tests are not even going to be run.Alternative Solutions
We can, of course, break a single test into multiple and mark them with
@pytest.mark.xfail
and@pytest.mark.skip
. This is less favorable because tests may be organized and can share some setup codes (which may not be exposed by fixture). Most importantly, we may want the test to early fail before it ever touches thewith pytest.xfail
block, and this is not achievable without the help of plugins likepytest-dependency
.Additional context
We would also like to see
strict=
argument in the currentpytest.xfail
.The text was updated successfully, but these errors were encountered: