Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-108885: Use subtests for doctest examples run by unittest#134890

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
serhiy-storchaka wants to merge1 commit intopython:main
base:main
Choose a base branch
Loading
fromserhiy-storchaka:doctest-subTest

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchakaserhiy-storchaka commentedMay 29, 2025
edited by github-actionsbot
Loading

Run each example as a subtest in unit tests synthesized by doctest.DocFileSuite() and doctest.DocTestSuite().


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

Comment on lines 1409 to 1411
except:
exception = sys.exc_info()
exc_info = sys.exc_info()
exc_info = (*exc_info[:2], exc_info[2].tb_next)
Copy link
Member

Choose a reason for hiding this comment

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

We don't need to use sys here:

except BaseException as e:    exc_info = type(e), e, e.__traceback__.tb_next

Copy link
Member

Choose a reason for hiding this comment

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

Alternatively, save just the exception here and access its parts below where you need them.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

It does not work, because a traceback here is a not a real traceback. You cannot set it as the part of the exception. Fortunately, all traceback formatting functions and TestCase.addSubTest() work with the exc_info triple.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Well,here it is a real traceback, but in other place we use a mock traceback, so it is easier to use the same pattern here.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I meant that you extract it from the exception object when you need it below (in this function) and pass that to the internal functions that want the triplet. Just get it from the exception and not from sys.exc_info(). It's the same thing.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

This line is actually a part of#134858.

iritkatriel reacted with thumbs up emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I applied your suggestion there.

Run each example as a subtest in unit tests synthesized bydoctest.DocFileSuite() and doctest.DocTestSuite().
@serhiy-storchaka
Copy link
MemberAuthor

Before merging this PR I am going to create a merge PR for documentation fixes, because the current documentation has some errors.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@iritkatrieliritkatrieliritkatriel approved these changes

@sobolevnsobolevnAwaiting requested review from sobolevn

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@serhiy-storchaka@iritkatriel

[8]ページ先頭

©2009-2025 Movatter.jp