-
-
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
Reference documentation, typing annotations and reality for pytest.mark.xfail()
don’t match
#10094
Comments
pytest.mark.xfail()
is wrongpytest.mark.xfail()
is wrong
pytest.mark.xfail()
is wrongpytest.mark.xfail()
don’t match
Hi @Zac-HD I would like to pick this up |
@TanyaAgarwal28 you don't need permission to open a PR, just go ahead. Like most maintainers, I'm a volunteer and prefer not to be pinged on issues or PRs - I'm already subscribed to everything I want notifications about. Someone will review your PRs when they have free time; and if they don't it could be a while. That's just how volunteer projects go! |
Allowing @pytest.mark.xfail(
# Argument of type "str | None" cannot be assigned to parameter "condition" of type "str | bool" in function "__call__" Pylance[reportGeneralTypeIssues]
# Argument 1 to "__call__" of "_XfailMarkDecorator" has incompatible type "Optional[str]"; expected "Union[str, bool]" Mypy[arg-type]
os.environ.get('PYTHONDONTWRITEBYTECODE'),
reason="Byte code disabled",
)
def test_exclude_source_files(self, setup_context, user_override): ... Where the current workaround is |
The documentation for
pytest.mark.xfail()
does not match reality.reason=None
: If no conditions are passed,reason
’s default is""
(code). Adding@pytest.mark.xfail(reason=None, strict=True)
to a passing test results in “TypeError: can only concatenate str (not "NoneType") to str”. If a condition is passed, passing noreason
behaves like passingNone
to it (code). I’m unsure how this subtlety could be captured in the function signature.pytest.mark.skipif()
has the same issue.pytest.mark.skip()
’s default value forreason
is in fact "unconditional skip" (code).raises
: The type (according to the type annotations) isUnion[Type[BaseException], Tuple[Type[BaseException], ...]]
instead ofType[Exception]
. Neither captures the fact thatNone
can be passed to it (which is also the documented default value).strict=False
: The default value ofstrict
is actually determined by thexfail_strict
config (code).The text was updated successfully, but these errors were encountered: