-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Fix skip signature #8392
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
Fix skip signature #8392
Conversation
The `--strict` argument was removed in pytest-dev#2552, but the removal wasn't actually correct - see pytest-dev#1472.
reason = "unconditional skip" | ||
return Skip(reason) | ||
try: | ||
return Skip(*mark.args, **mark.kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the existing __init__
rather than hand-rolling argument parsing will also catch other issues, like giving too many arguments to the mark. All those were silently ignored before.
@@ -861,9 +861,25 @@ def test_hello(): | |||
pass | |||
""" | |||
) | |||
result = pytester.runpytest("-rs") | |||
result = pytester.runpytest("-rs", "--strict-markers") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not directly related, see #2552 (comment)
src/_pytest/skipping.py
Outdated
try: | ||
return Skip(*mark.args, **mark.kwargs) | ||
except TypeError as e: | ||
raise TypeError(str(e) + " - maybe you meant pytest.mark.skipif?") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not doing "from e" here because it's not really relevant to the user where the exception comes from.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would from None Make sense to completely suppress it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable - added!
Yeah it is a bit ambiguous, but IMHO the breaking change only happens because of misuse (according to the documentation), plus the misuse is hiding a problem, so I consider it a bugfix. 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lovely
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me - and I'd be happy to close #8384 on the basis that skip and skipif are now clearly distinct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks everyone for the quick reviews!
Not sure if this should qualify as a bugfix, or if it should rather be a breaking change? Though affected tests were silently skipped before, which seems quite bad.