Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8c53381

Browse files
fix: Switch to unittest.mock from mock (#713)
* test: Switch to unittest.mock from mockNow that the minimum supported version of Python is 3.7, we can stopusing the external mock requirement, and import it from unittest. I havealso attempted to keep imports ordered.Fixes#377* test: Fallback to external mock for AsyncMockAsyncMock is not included in unittest.mock under Python 3.7, so we mustfallback to the external mock requirement for that Python version. Onlyinstall it for that version.Keep this as a separate commit so it can be reverted when 3.7 isn'tsupported anymore.* lint* clean up to satisfy mypy* lint* fix build---------Co-authored-by: Anthonios Partheniou <partheniou@google.com>
1 parentb2baf47 commit8c53381

25 files changed

+83
-31
lines changed

‎noxfile.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def default(session, install_grpc=True, prerelease=False, install_async_rest=Fal
124124

125125
session.install(
126126
"dataclasses",
127-
"mock",
127+
"mock; python_version=='3.7'",
128128
"pytest",
129129
"pytest-cov",
130130
"pytest-xdist",
@@ -280,8 +280,8 @@ def mypy(session):
280280
"types-setuptools",
281281
"types-requests",
282282
"types-protobuf",
283-
"types-mock",
284283
"types-dataclasses",
284+
"types-mock; python_version=='3.7'",
285285
)
286286
session.run("mypy","google","tests")
287287

‎tests/asyncio/future/test_async_future.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
# limitations under the License.
1414

1515
importasyncio
16+
fromunittestimportmock
1617

17-
importmock
1818
importpytest
1919

2020
fromgoogle.api_coreimportexceptions

‎tests/asyncio/gapic/test_method_async.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414

1515
importdatetime
1616

17-
importmock
17+
try:
18+
fromunittestimportmock
19+
fromunittest.mockimportAsyncMock# pragma: NO COVER # noqa: F401
20+
exceptImportError:# pragma: NO COVER
21+
importmock# type: ignore
1822
importpytest
1923

2024
try:

‎tests/asyncio/operations_v1/test_operations_async_client.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
importmock
15+
fromunittestimportmock
16+
1617
importpytest
1718

1819
try:

‎tests/asyncio/retry/test_retry_streaming_async.py‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,16 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
importasyncio
1516
importdatetime
1617
importre
17-
importasyncio
1818

19-
importmock
19+
try:
20+
fromunittestimportmock
21+
fromunittest.mockimportAsyncMock# pragma: NO COVER # noqa: F401
22+
exceptImportError:# pragma: NO COVER
23+
importmock# type: ignore
24+
2025
importpytest
2126

2227
fromgoogle.api_coreimportexceptions

‎tests/asyncio/retry/test_retry_unary_async.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515
importdatetime
1616
importre
1717

18-
importmock
18+
try:
19+
fromunittestimportmock
20+
fromunittest.mockimportAsyncMock# pragma: NO COVER # noqa: F401
21+
exceptImportError:# pragma: NO COVER
22+
importmock# type: ignore
1923
importpytest
2024

2125
fromgoogle.api_coreimportexceptions

‎tests/asyncio/test_grpc_helpers_async.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
importmock
15+
try:
16+
fromunittestimportmock
17+
fromunittest.mockimportAsyncMock# pragma: NO COVER # noqa: F401
18+
exceptImportError:# pragma: NO COVER
19+
importmock# type: ignore
1620
importpytest# noqa: I202
1721

1822
try:

‎tests/asyncio/test_operation_async.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,14 @@
1313
# limitations under the License.
1414

1515

16-
importmock
1716
importpytest
1817

18+
try:
19+
fromunittestimportmock
20+
fromunittest.mockimportAsyncMock# pragma: NO COVER # noqa: F401
21+
exceptImportError:# pragma: NO COVER
22+
importmock# type: ignore
23+
1924
try:
2025
importgrpc# noqa: F401
2126
exceptImportError:# pragma: NO COVER

‎tests/asyncio/test_page_iterator_async.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414

1515
importinspect
1616

17-
importmock
17+
try:
18+
fromunittestimportmock
19+
fromunittest.mockimportAsyncMock# pragma: NO COVER # noqa: F401
20+
exceptImportError:# pragma: NO COVER
21+
importmock# type: ignore
1822
importpytest
1923

2024
fromgoogle.api_coreimportpage_iterator_async

‎tests/asyncio/test_rest_streaming_async.py‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,20 @@
1515
# TODO: set random.seed explicitly in each test function.
1616
# See related issue: https://github.com/googleapis/python-api-core/issues/689.
1717

18-
importpytest# noqa: I202
19-
importmock
20-
2118
importdatetime
2219
importlogging
2320
importrandom
2421
importtime
2522
fromtypingimportList,AsyncIterator
2623

24+
try:
25+
fromunittestimportmock
26+
fromunittest.mockimportAsyncMock# pragma: NO COVER # noqa: F401
27+
exceptImportError:# pragma: NO COVER
28+
importmock# type: ignore
29+
30+
importpytest# noqa: I202
31+
2732
importproto
2833

2934
try:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp