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

gh-108794: doctest counts skipped tests #108795

Merged
merged 5 commits into from
Sep 2, 2023
Merged

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Sep 2, 2023

  • Add 'skipped' attribute to doctest.TestResults.
  • Rename private DocTestRunner._name2ft attribute to DocTestRunner._stats.
  • Use f-string for string formatting.
  • Add some tests.

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

* Add 'skipped' attribute to doctest.TestResults.
* Rename private DocTestRunner._name2ft attribute
  to DocTestRunner._stats.
* Use f-string for string formatting.
* Add some tests.
@vstinner
Copy link
Member Author

vstinner commented Sep 2, 2023

When a doctest.TestResults is unpacked with x, y = result, there is no backward incompatible changes. TestResults still only unpacks the first 2 members (failed and attempted).

Example: failed, attempted = result.

@vstinner
Copy link
Member Author

vstinner commented Sep 2, 2023

I wrote this enhancement while working on #108793 which logs the number of executed tests.

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice feature! A few docs nits:

Doc/library/doctest.rst Outdated Show resolved Hide resolved
Doc/library/doctest.rst Outdated Show resolved Hide resolved
Lib/doctest.py Outdated Show resolved Hide resolved
Lib/doctest.py Outdated Show resolved Hide resolved
Lib/doctest.py Outdated Show resolved Hide resolved
Lib/doctest.py Outdated Show resolved Hide resolved
Lib/doctest.py Outdated Show resolved Hide resolved
Document also DocTestRunner API for statistics, document its
attributes.
@vstinner
Copy link
Member Author

vstinner commented Sep 2, 2023

@AlexWaygood: Would you mind to review the updated PR?

I updated my PR to address your remarks. I also renamed DocTestRunner.skipped to DocTestRunner.skips for consistency with existing attributes. Sadly, DocTestRunner and TestResults have different attribute names.

@vstinner
Copy link
Member Author

vstinner commented Sep 2, 2023

cc @tim-one

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more minor suggestions:

Doc/library/doctest.rst Outdated Show resolved Hide resolved
Doc/library/doctest.rst Outdated Show resolved Hide resolved
Doc/whatsnew/3.13.rst Outdated Show resolved Hide resolved
@vstinner
Copy link
Member Author

vstinner commented Sep 2, 2023

@AlexWaygood: Oh thanks, I addressed your second review. I also mentioned the addition of the skips attribute in What's New/Changelog entry.

Copy link
Member

@AlexWaygood AlexWaygood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Doc/whatsnew/3.13.rst Outdated Show resolved Hide resolved
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
@vstinner vstinner merged commit 4f9b706 into python:main Sep 2, 2023
22 checks passed
@vstinner vstinner deleted the doctest_skipped branch September 2, 2023 14:42
@vstinner
Copy link
Member Author

vstinner commented Sep 2, 2023

Thanks for the great review @AlexWaygood! I merged my PR.

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 this pull request may close these issues.

3 participants