GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: use mock from unittest if available by major · Pull Request #957 · googleapis/gapic-generator-python

This repository was archived by the owner on Aug 25, 2026. It is now read-only.

Conversation

@major

@major major commented Jul 15, 2021

Copy link
Copy Markdown

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@major
fix: use mock from unittest if available
c3c1f14
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 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
tseaver
tseaver reviewed Jul 15, 2021
View reviewed changes

@tseaver tseaver left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this 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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@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

major commented Jul 15, 2021

Copy link
Copy Markdown
Author

@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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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

tseaver commented Jul 15, 2021

Copy link
Copy Markdown
Contributor

@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).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@busunkim96 busunkim96 mentioned this pull request Oct 15, 2021
test_iam_credentials.py imports mock, but this fails on Python 3.10 googleapis/python-iam#96
Closed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

1 more reviewer
@tseaver tseaver tseaver left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

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

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@major @tseaver
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.