Skip to content

Conversation

@DinoV
Copy link
Contributor

@DinoV DinoV commented Feb 4, 2020

The fix for bpo-17636 added support for falling back to sys.modules when a module isn't directly present on the module. But mock doesn't have the same behavior - it'll try the import, and then try to get the value off the object. If it's not there it just errors out.

Instead it should also consult sys.modules to be consistent with import semantics.

This checks to see if the attribute is defined, and if it is returns it matching the existing behavior. If the attribute isn't defined it'll fallback to sys.modules.

https://bugs.python.org/issue39551

Copy link
Member

@iritkatriel iritkatriel left a comment

Choose a reason for hiding this comment

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

This has merge conflicts now.

@bedevere-bot
Copy link

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

Copy link
Contributor

@voidspace voidspace left a comment

Choose a reason for hiding this comment

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

LGTM

One question - why manually use p1/p2 .start and .stop - is there a stopall in tearDown? Using patch as a context manager would seem more natural.

@DinoV DinoV closed this May 31, 2024
@DinoV DinoV deleted the bp39551 branch May 31, 2024 18:23
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.

7 participants