Skip to content

gh-108794: doctest counts skipped tests - #108795

Merged
vstinner merged 5 commits into
python:mainfrom
vstinner:doctest_skipped
Sep 2, 2023
Merged

vstinner merged 5 commits into
python:mainfrom
vstinner:doctest_skipped

Conversation

@vstinner

@vstinner vstinner commented Sep 2, 2023 •

Copy link
Copy Markdown
Member
  • 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

vstinner commented Sep 2, 2023

Copy link
Copy Markdown
Member Author

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

vstinner commented Sep 2, 2023

Copy link
Copy Markdown
Member Author

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

@AlexWaygood AlexWaygood left a comment

Copy link
Copy Markdown
Member

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:

Comment thread Doc/library/doctest.rst Resolved
Comment thread Doc/library/doctest.rst Resolved
Comment thread Lib/doctest.py Resolved
Comment thread Lib/doctest.py Resolved
Comment thread Lib/doctest.py Resolved
Comment thread Lib/doctest.py Resolved
Comment thread Lib/doctest.py Resolved
Document also DocTestRunner API for statistics, document its
attributes.
@vstinner

vstinner commented Sep 2, 2023

Copy link
Copy Markdown
Member Author

@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

vstinner commented Sep 2, 2023

Copy link
Copy Markdown
Member Author

@AlexWaygood AlexWaygood left a comment

Copy link
Copy Markdown
Member

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:

Comment thread Doc/library/doctest.rst Resolved
Comment thread Doc/library/doctest.rst Resolved
Comment thread Doc/whatsnew/3.13.rst Resolved
@vstinner

vstinner commented Sep 2, 2023

Copy link
Copy Markdown
Member Author

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

@AlexWaygood AlexWaygood left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

Comment thread Doc/whatsnew/3.13.rst Resolved
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
@vstinner
vstinner merged commit 4f9b706 into python:main Sep 2, 2023
@vstinner
vstinner deleted the doctest_skipped branch September 2, 2023 14:42
@vstinner

vstinner commented Sep 2, 2023

Copy link
Copy Markdown
Member Author

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

3 participants