GeezerVison is showing github.com — gh-117364: Add `doctest.SkipTest` to skip all or some doctest examples by sobolevn · Pull Request #122935 · python/cpython
Conversation
sobolevn
commented
Aug 12, 2024
•
edited by github-actions
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
I ended up with an exception instead of a decorator. Several reasons:
- Exception allows skipping some parts of doctest, giving more flexibility:
>>> 'is not ' + 'skipped'
'is not skipped'
>>> import doctest
>>> raise doctest.SkipTest("All examples after are skipped")
>>> 'skipped'
'not checked'
- It will work with
testsource and other text-based features. While @skip_if decorator required real objects with attributes.
- 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/
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
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 reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Thanks for the info, would love to see better unittest + doctest intergration. Marking this as a draft for now.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
This PR is stale because it has been open for 30 days with no activity.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
This PR is blocked on its author, has not been touched by a human in more than 2 years, and no longer merges cleanly. Closing to cull the number of open pull requests. Do not reopen this pull request without getting a go-ahead from a triager or core developer on gh-117364.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
stale
Stale PR or inactive for long period of time.
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.