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

gh-108794: doctest counts skipped tests#108795
vstinner merged 5 commits into
python:mainfrom
vstinner:doctest_skipped

Conversation

@vstinner

@vstinnervstinner 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

Copy link
Copy Markdown
MemberAuthor

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
Copy Markdown
MemberAuthor

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

@AlexWaygoodAlexWaygood 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 threadDoc/library/doctest.rst Outdated
Comment threadDoc/library/doctest.rst Outdated
Comment threadLib/doctest.py Outdated
Comment threadLib/doctest.py Outdated
Comment threadLib/doctest.py Outdated
Comment threadLib/doctest.py Outdated
Comment threadLib/doctest.py Outdated
Document also DocTestRunner API for statistics, document its
attributes.
@vstinner

Copy link
Copy Markdown
MemberAuthor

@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
Copy Markdown
MemberAuthor

cc @tim-one

@AlexWaygoodAlexWaygood 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 threadDoc/library/doctest.rst Outdated
Comment threadDoc/library/doctest.rst Outdated
Comment threadDoc/whatsnew/3.13.rst Outdated
Comment threadMisc/NEWS.d/next/Tests/2023-09-02-05-13-38.gh-issue-108794.tGHXBt.rst Outdated
@vstinner

Copy link
Copy Markdown
MemberAuthor

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

@AlexWaygoodAlexWaygood 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 threadDoc/whatsnew/3.13.rst Outdated
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
@vstinner
vstinner merged commit 4f9b706 into python:mainSep 2, 2023
@vstinner
vstinner deleted the doctest_skipped branch September 2, 2023 14:42
@vstinner

Copy link
Copy Markdown
MemberAuthor

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

Sign up for freeto 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

@vstinner@AlexWaygood@bedevere-bot