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

Add support for :skipif: #9

Open
2 of 4 tasks
twmr opened this issue May 10, 2019 · 8 comments · May be fixed by #10
Open
2 of 4 tasks

Add support for :skipif: #9

twmr opened this issue May 10, 2019 · 8 comments · May be fixed by #10

Comments

@twmr
Copy link
Owner

twmr commented May 10, 2019

See http://www.sphinx-doc.org/en/master/usage/extensions/doctest.html#skipping-tests-conditionally

  • in testoutput
  • in testcode
  • in doctest
  • in testsetup/testcleanup
This was referenced Jun 6, 2019
@dc3671
Copy link

dc3671 commented Apr 1, 2020

I need that, too!

@twmr
Copy link
Owner Author

twmr commented Apr 1, 2020

Before I can continue working on this I need to do some preparations, one of them is to add a test-framework that runs sphinx-build -M doctest. This is needed for making sure that pytest-sphinx treats the doctests the same way as sphinx.

@twmr
Copy link
Owner Author

twmr commented Apr 19, 2020

I'll soon upload a PR for adding support for :skipif: in `..testoutput``.

@dc3671 In which directives do you want to use :skipif:?

@dc3671
Copy link

dc3671 commented Apr 21, 2020

@Thisch just .. testoutput is fine. Supporting .. testcode is better.

@twmr
Copy link
Owner Author

twmr commented Apr 21, 2020

I'll probably release a new version of pytest-sphinx containing support for :skipif: in all directives next week.

@twmr
Copy link
Owner Author

twmr commented Apr 22, 2020

@Thisch just .. testoutput is fine. Supporting .. testcode is better.

Done in #21.

@jab
Copy link

jab commented Feb 6, 2022

Hi @Thisch, just found my way to this issue and am wondering about the status. I'm specifically interested in "skipif" support for .. doctest. I see this issue is still open and the "in doctest" checkbox in the description is unchecked, but I also see:

On Apr 21, 2020 you wrote:

I'll probably release a new version of pytest-sphinx containing support for :skipif: in all directives next week.

...and there was in fact a new version released a few months later, though https://github.com/thisch/pytest-sphinx/blob/master/CHANGELOG.md#03---2020-08-04 doesn't mention skipif support for .. doctest. So I'm guessing this is still to-do. If so, are you still thinking of getting to this soon?

Thanks for maintaining this package, and looking forward to being able to hopefully use it once this issue is fixed.

jab added a commit to jab/bidict that referenced this issue Jan 4, 2023
* Use pytest-sphinx to have pytest run doctests in Sphinx docs rather
  than using Sphinx to run these via run_tests.py.

  * Sphinx is no longer a test dependency, which allows upgrading to
    Sphinx 6.0 while still being able to run the tests with Python 3.7.
    (Sphinx 6.0 dropped support for 3.7.)

  * Use conftest.py rather than testsetup or doctest_global_setup, which
    pytest-sphinx does not currently support.

  * Don't use :skipif: in doctest:: directives since pytest-sphinx does
    not currently support it (twmr/pytest-sphinx#9). Instead just
    don't ever run the one doctest that was using this, since the
    behavior it was testing is also covered by several tests in
    test_properties.py that do still properly get run conditionally
    (specifically, the "freed on zero refcount" tests are still run on
    CPython but not PyPy).

  * Don't use >>> for code we don't want to test, since pytest-sphinx
    will otherwise still run it even if it's in a code-block directive
    (and sprinkling `# doctest: SKIP` everywhere as an alternative is
    noisy).

* Add pytest-clarity to dev dependencies and pass -vv to pytest by
  default to enable pytest-clarity's nicer diffs in development.
@jab
Copy link

jab commented Jan 4, 2023

Just hit a related issue combining the recommended workaround for #5 with the current :skipif: support.

Mentioning here in case it's worth adding an associated checkbox to this issue's description.

jab added a commit to jab/bidict that referenced this issue Jan 4, 2023
* Use pytest-sphinx to have pytest run doctests in Sphinx docs rather
  than using Sphinx to run these via run_tests.py.

  * Sphinx is no longer a test dependency, which allows upgrading to
    Sphinx 6.0 while still being able to run the tests with Python 3.7.
    (Sphinx 6.0 dropped support for 3.7.)

  * Use conftest.py rather than testsetup or doctest_global_setup, which
    pytest-sphinx does not currently support.

  * Don't use :skipif: in doctest:: directives since pytest-sphinx does
    not currently support it (twmr/pytest-sphinx#9). Instead just
    don't ever run the one doctest that was using this, since the
    behavior it was testing is also covered by several tests in
    test_properties.py that do still properly get run conditionally
    (specifically, the "freed on zero refcount" tests are still run on
    CPython but not PyPy).

  * Don't use >>> for code we don't want to test, since pytest-sphinx
    will otherwise still run it even if it's in a code-block directive
    (and sprinkling `# doctest: SKIP` everywhere as an alternative is
    noisy).

* Add pytest-clarity to dev dependencies and pass -vv to pytest by
  default to enable pytest-clarity's nicer diffs in development.
jab added a commit to jab/bidict that referenced this issue Jan 4, 2023
* Use pytest-sphinx to have pytest run doctests in Sphinx docs rather
  than using Sphinx to run these via run_tests.py.

  * Sphinx is no longer a test dependency, which allows upgrading to
    Sphinx 6.0 while still being able to run the tests with Python 3.7.
    (Sphinx 6.0 dropped support for 3.7.)

  * Use conftest.py rather than testsetup or doctest_global_setup, which
    pytest-sphinx does not currently support.

  * Don't use :skipif: in doctest:: directives since pytest-sphinx does
    not currently support it (twmr/pytest-sphinx#9). Instead just
    don't ever run the one doctest that was using this, since the
    behavior it was testing is also covered by several tests in
    test_properties.py that do still properly get run conditionally
    (specifically, the "freed on zero refcount" tests are still run on
    CPython but not PyPy).

  * Don't use >>> for code we don't want to test, since pytest-sphinx
    will otherwise still run it even if it's in a code-block directive
    (and sprinkling `# doctest: SKIP` everywhere as an alternative is
    noisy).

* Add pytest-clarity to dev dependencies and pass -vv to pytest by
  default to enable pytest-clarity's nicer diffs in development.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants