FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-131031: Fix separated running of `pickle` tests by donbarbos · Pull Request #133218 · python/cpython · GitHub

/ cpython Public

gh-131031: Fix separated running of pickle tests - #133218

Closed
donbarbos wants to merge 2 commits into
python:mainfrom
donbarbos:issue-131031
Closed

gh-131031: Fix separated running of pickle tests#133218
donbarbos wants to merge 2 commits into
python:mainfrom
donbarbos:issue-131031

Conversation

donbarbos commented Apr 30, 2025
edited
Loading

Copy link
Copy Markdown
Contributor

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

donbarbos changed the title Fix separated running of pickle tests gh-131031: Fix separated running of pickle tests Apr 30, 2025

Copy link
Copy Markdown
Contributor Author

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

tomasr8 commented Apr 30, 2025

Copy link
Copy Markdown
Member

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

donbarbos marked this pull request as draft May 1, 2025 21:43

donbarbos commented May 3, 2025
edited
Loading

Copy link
Copy Markdown
Contributor Author

@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

donbarbos marked this pull request as ready for review May 3, 2025 17:02

tomasr8 commented May 3, 2025

Copy link
Copy Markdown
Member

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

This comment was marked as abuse.

This comment was marked as abuse.

serhiy-storchaka 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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Good PR, but using a global class which is not imported in test_pickle.py instead of AbstractPickleTests 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.

Comment thread Lib/test/pickletester.py
real_main = sys.modules.get("__main__")
fake_main = types.ModuleType("__main__")

sys.modules["__main__"] = fake_main

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

donbarbos closed this May 3, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL