-
-
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
Make pytest.skip work in doctest #4927
Conversation
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 in general.
Thanks. I added a test and some lines in docstring. I think it is ready for review. |
src/_pytest/outcomes.py
Outdated
@@ -80,7 +80,8 @@ def skip(msg="", **kwargs): | |||
Skip an executing test with the given message. | |||
|
|||
This function should be called only during testing (setup, call or teardown) or | |||
during collection by using the ``allow_module_level`` flag. | |||
during collection by using the ``allow_module_level`` flag. This function can | |||
be called in doctest as well. |
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.
be called in doctest as well. | |
be called in doctests as well. |
But not sure if it is useful to mention doctests here explicitly..?!
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 OK either way. I thought to mention it since doctests are special enough for how they are executed but yet very popular.
Co-Authored-By: tkf <takafumi.a@gmail.com>
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!
Co-Authored-By: tkf <takafumi.a@gmail.com>
Thanks a lot! |
no, thanks you! good patch :D |
Awesome @tkf! Glad I was incorrect in my first assessment then! 😁 |
For reference: #6669 adds it for all OutcomeExceptions (xfail, importorskip). |
As discussed in #4911 (comment), it would be nice if doctest can be conditionally skipped. It seems that just adding three lines is enough (close #4911). All this patch does is throwing
Skipped
instead ofUnexpectedException
if the original exception isSkipped
.I'll add tests and docs if this direction looks OK.
changelog
folder, with a name like<ISSUE NUMBER>.<TYPE>.rst
. See changelog/README.rst for details.Target themaster
branch for bug fixes, documentation updates and trivial changes.features
branch for new features and removals/deprecations.Unless your change is trivial or a small documentation fix (e.g., a typo or reword of a small section) please:
AUTHORS
in alphabetical order;