Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use mock from unittest if available #957

Closed
wants to merge 1 commit into from

Conversation

major
Copy link

@major major commented Jul 15, 2021

Try to import mock from the unittest builtin package if possible, otherwise fall back to importing the mock package.

Try to import `mock` from the `unittest` builtin package if possible,
otherwise fall back to importing the `mock` package.
@major major requested a review from a team as a code owner July 15, 2021 18:09
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Jul 15, 2021
Copy link
Contributor

@tseaver tseaver left a comment

Choose a reason for hiding this comment

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

In an ideal world, we would just have from unittest import mock (the generated code no longer has to support Python 2.7). However, the stdlib versions of unittest.mock is missing some features from the third-party shim: notably, the 3.6 and 3.7 versions lack mock.AsyncMock, which we need even for some synchronous tests.

@tseaver tseaver added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Jul 15, 2021
@major
Copy link
Author

major commented Jul 15, 2021

@tseaver Okay, thanks for the explanation. I'm packaging some things for Fedora Linux and I'll carry a patch to make these tests work.

@major major closed this Jul 15, 2021
@major major deleted the patch-1 branch July 15, 2021 18:57
@tseaver
Copy link
Contributor

tseaver commented Jul 15, 2021

@major Thank you for the patch! I'm sorry we are stuck with supporting the older Python3 versions -- in fact, I knew about the mock.AsyncMock bit because I have been working on dropping Python 2.7 support from the core libraries (see this PR where I first noticed it).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement. do not merge Indicates a pull request not ready for merge, due to either quality or timing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants