Skip to content

gh-117364: Add doctest.SkipTest to skip all or some doctest examples - #122935

Draft
sobolevn wants to merge 2 commits into
python:mainfrom
sobolevn:issue-117364
Draft

gh-117364: Add doctest.SkipTest to skip all or some doctest examples#122935
sobolevn wants to merge 2 commits into
python:mainfrom
sobolevn:issue-117364

Conversation

@sobolevn

@sobolevnsobolevn commented Aug 12, 2024

Copy link
Copy Markdown
Member

I ended up with an exception instead of a decorator. Several reasons:

  1. Exception allows skipping some parts of doctest, giving more flexibility:
>>>'is not '+'skipped''is not skipped'>>>importdoctest>>>raisedoctest.SkipTest("All examples after are skipped")
>>>'skipped''not checked'
  1. It will work with testsource and other text-based features. While @skip_if decorator required real objects with attributes.
  2. The API change is simplier with an exception. It only adds one new object. While decorator required a lot of new parameters in existing functions.

📚 Documentation preview 📚: https://cpython-previews--122935.org.readthedocs.build/

@sobolevn

Copy link
Copy Markdown
MemberAuthor

@serhiy-storchaka friendly ping :)

@serhiy-storchaka

Copy link
Copy Markdown
Member

Thank you for the reminder @sobolevn.

I worked on better integration of doctests with unittests (#108885). In these plans every doctest example is counted as a subtest. Raising unittest.SkipTest only skips a single subtest, not all following subtests. This difference between unittest.SkipTest and doctest.SkipTest may be confusing. On other hand, raising unittest.SkipTest outside of a subTest() block skips the whole test. Since the line that raises doctest.SkipTest does not have an expected output or traceback, it may be not counted as example.

So I want to try to make more progress on that issue first. Than we will see how it works together and what API is better for skipping doctests.

@sobolevn

Copy link
Copy Markdown
MemberAuthor

Thanks for the info, would love to see better unittest + doctest intergration. Marking this as a draft for now.

@sobolevn
sobolevn marked this pull request as draft October 19, 2024 11:04
@github-actions

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actionsgithub-actionsBot added the stale Stale PR or inactive for long period of time. label Apr 18, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

staleStale PR or inactive for long period of time.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@sobolevn@serhiy-storchaka