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: Switch to unittest.mock from mock #713

Merged
merged 7 commits into from
Oct 9, 2024

Conversation

s-t-e-v-e-n-k
Copy link
Contributor

@s-t-e-v-e-n-k s-t-e-v-e-n-k commented Oct 2, 2024

Now that the minimum supported version of Python is 3.7, we can stop using the external mock requirement, and import it from unittest. I have also attempted to keep imports ordered.

Fixes #377
Closes #676

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

@s-t-e-v-e-n-k s-t-e-v-e-n-k requested review from a team as code owners October 2, 2024 03:53
@product-auto-label product-auto-label bot added the size: m Pull request size is medium. label Oct 2, 2024
Now that the minimum supported version of Python is 3.7, we can stop
using the external mock requirement, and import it from unittest. I have
also attempted to keep imports ordered.

Fixes googleapis#377
@s-t-e-v-e-n-k s-t-e-v-e-n-k force-pushed the switch-to-unittest-mock branch from 4db4bbf to 5f28e21 Compare October 2, 2024 03:54
@ohmayr
Copy link
Contributor

ohmayr commented Oct 2, 2024

@s-t-e-v-e-n-k, general comment: AsyncMock isn't part of the stdlib i.e. unitest.mock for Python 3.7. which we're using in our test code.

@s-t-e-v-e-n-k
Copy link
Contributor Author

Ahh, indeed, AsyncMock was added in 3.8. I'll modify this accordingly.

AsyncMock is not included in unittest.mock under Python 3.7, so we must
fallback to the external mock requirement for that Python version. Only
install it for that version.

Keep this as a separate commit so it can be reverted when 3.7 isn't
supported anymore.
@s-t-e-v-e-n-k s-t-e-v-e-n-k force-pushed the switch-to-unittest-mock branch from 98f3bec to 5583db4 Compare October 3, 2024 11:44
@parthea parthea self-assigned this Oct 9, 2024
@parthea parthea changed the title Switch to unittest.mock from mock fix: Switch to unittest.mock from mock Oct 9, 2024
@parthea parthea merged commit 8c53381 into googleapis:main Oct 9, 2024
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

use unittest.mock instead of mock
3 participants