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-131031: Fix separated running ofpickle tests#133218

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

Closed
donBarbos wants to merge2 commits intopython:mainfromdonBarbos:issue-131031

Conversation

@donBarbos
Copy link
Contributor

@donBarbosdonBarbos commentedApr 30, 2025
edited
Loading

I found that tests stopped running successfully directly afterthis commit (PR#122373)

@donBarbosdonBarbos changed the titleFix separated running ofpickle testsgh-131031: Fix separated running ofpickle testsApr 30, 2025
@donBarbos
Copy link
ContributorAuthor

cc@tomasr8 (sorry for choosing you but current pickle expert is inactive)

@tomasr8
Copy link
Member

Are you sure the assertions are being executed? Sinceself.dumps(obj, proto) raises, anything that comes after in the with block will not execute.

@donBarbosdonBarbos marked this pull request as draftMay 1, 2025 21:43
@donBarbos
Copy link
ContributorAuthor

donBarbos commentedMay 3, 2025
edited
Loading

@tomasr8 sorry for the first commit.
As far as I know, changing__main__ is bad practice, but it seems that this issue cannot be solved otherwise, since the problem is that__main__ is different for different launch methods, and I was inspired by a similar PR#131371

@donBarbosdonBarbos marked this pull request as ready for reviewMay 3, 2025 17:02
@tomasr8
Copy link
Member

This looks ok, but I'm not expert in his area :/@serhiy-storchaka could you have a look?

@jasonzitao

This comment was marked as abuse.

@jasonzitao

This comment was marked as abuse.

Copy link
Member

@serhiy-storchakaserhiy-storchaka left a comment

Choose a reason for hiding this comment

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

Good PR, but using a global class which is not imported intest_pickle.py instead ofAbstractPickleTests would fix the tests too. See#133356.

Faking the__main__ module looks heavyweight, we don't know what side effects can it have. We would use this approach if there was no other way.

donBarbos and tomasr8 reacted with thumbs up emoji
real_main=sys.modules.get("__main__")
fake_main=types.ModuleType("__main__")

sys.modules["__main__"]=fake_main

Choose a reason for hiding this comment

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

You can usesupport.swap_item(). It is already used in other tests to fake a module.

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

Reviewers

@serhiy-storchakaserhiy-storchakaserhiy-storchaka left review comments

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@donBarbos@tomasr8@jasonzitao@serhiy-storchaka

[8]ページ先頭

©2009-2025 Movatter.jp