Skip to content
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

Rule that suggests explicit strict= in @pytest.mark.xfail #267

Open
lengau opened this issue Oct 24, 2023 · 2 comments
Open

Rule that suggests explicit strict= in @pytest.mark.xfail #267

lengau opened this issue Oct 24, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@lengau
Copy link

lengau commented Oct 24, 2023

Rule request

Description

Detect use of the @pytest.mark.xfail decorator and ensure it explicitly sets a strict=True or strict=False rather than allowing silent (and possibly accidental) use of the default False configuration.

Rationale

The pytest.mark.xfail decorator has a strict parameter that defaults to False, making xfail in CI roughly equivalent to a skip rather than failing if the test passes. This would prevent accidentally committing xfail tests that get hidden in CI.

@m-burst
Copy link
Owner

m-burst commented Nov 2, 2023

Hi @lengau,

Thanks for the issue!
Unfortunately I'm not sure about it.
I agree that strict xfail should always be preferred to non-strict, but it is probably better to set it globally in the config file, instead of bugging developers with lint errors on each individual test.

There already is issue #24 which suggests to verify that the config file follows the best practices (including xfail_strict = True)

@RonnyPfannschmidt
Copy link

the plan in pytest is to make xfail strict by default again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants