-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Add more info about skipping doctests #8080
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
Conversation
nicoddemus
left a comment
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.
Hi @prakhargurunani, thanks a lot for the contribution!
However it is not entirely correct, #7429 is about pytest.skip inside doctests, not at the module level. The examples and docs you provided are using pytest.skip in normal test code.
As an example, see this module (note this is not a test module, but just a normal Python module with doctests on it):
def foobar_pytest_skip():
"""
>>> import pytest, sys
>>> if sys.platform.startswith('win'):
... pytest.skip('skip doctest for foobar_pytest_skip on Windows')
>>> 1 + 2
3
>>> "foo" + "bar"
'foobar'
"""
def foobar_doctest_skip():
"""
>>> 1 + 4 # doctest: +SKIP
3
>>> "foo" + "bar"
'foobar'
"""
def foobar_pytest_xfail():
"""
>>> import pytest, sys
>>> if sys.platform.startswith('win'):
... pytest.xfail('xfail doctest for foobar_pytest_xfail on Windows')
>>> 1 + 2
3
>>> "foo" + "bar"
'foobar'
"""Output:
λ pytest --doctest-modules -v --no-header
======================================= test session starts =======================================
collected 3 items
foo.py::foo.foobar_doctest_skip PASSED [ 33%]
foo.py::foo.foobar_pytest_skip SKIPPED [ 66%]
foo.py::foo.foobar_pytest_xfail XFAIL [100%]
============================= 1 passed, 1 skipped, 1 xfailed in 0.22s =============================
So this example already answers the questions from #7429:
It is not clear where to put this skip-line into. The module? The specific docstring?
It should be in the specific docstring.
Does it apply to every doctest definition in the file?
No, just to that docstring.
It could be mentioned that # doctest: +SKIP skips a single line/doctest, which is what most people search for(?). A sentence if xfailis possible would also be great.
Indeed, the examples above showcase that.
Could you update your PR adding the proper examples and docs? Thanks!
cc @spaceone
nicoddemus
left a comment
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 @prakhargurunani!
Took the liberty of taking your examples and improve that section overall. 👍
If this change fixes an issue, please:
fixes: clarify documentation about skipping of doctests #7429
clarify documentation about skipping of doctests
Create a new changelog file in the
changelogfolderAdd yourself to
AUTHORSin alphabetical order.