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

Commit09cf285

Browse files
authored
tests: add testing w/o 'grpc' installed (#289)
Closes#288.
1 parentf4e776e commit09cf285

16 files changed

+124
-12
lines changed

‎noxfile.py‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
nox.options.sessions= [
3434
"unit",
3535
"unit_grpc_gcp",
36+
"unit_wo_grpc",
3637
"cover",
3738
"pytype",
3839
"mypy",
@@ -78,7 +79,7 @@ def blacken(session):
7879
session.run("black",*BLACK_EXCLUDES,*BLACK_PATHS)
7980

8081

81-
defdefault(session):
82+
defdefault(session,install_grpc=True):
8283
"""Default unit test session.
8384
8485
This is intended to be run **without** an interpreter set, so
@@ -92,7 +93,10 @@ def default(session):
9293

9394
# Install all test dependencies, then install this package in-place.
9495
session.install("mock","pytest","pytest-cov")
95-
session.install("-e",".[grpc]","-c",constraints_path)
96+
ifinstall_grpc:
97+
session.install("-e",".[grpc]","-c",constraints_path)
98+
else:
99+
session.install("-e",".","-c",constraints_path)
96100

97101
pytest_args= [
98102
"python",
@@ -140,6 +144,12 @@ def unit_grpc_gcp(session):
140144
default(session)
141145

142146

147+
@nox.session(python=["3.6","3.10"])
148+
defunit_wo_grpc(session):
149+
"""Run the unit test suite w/o grpcio installed"""
150+
default(session,install_grpc=False)
151+
152+
143153
@nox.session(python="3.6")
144154
deflint_setup_py(session):
145155
"""Verify that setup.py is valid (including RST check)."""

‎tests/asyncio/gapic/test_config_async.py‎

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

15+
16+
importpytest
17+
18+
try:
19+
importgrpc# noqa: F401
20+
exceptImportError:
21+
pytest.skip("No GRPC",allow_module_level=True)
22+
1523
fromgoogle.api_coreimportexceptions
1624
fromgoogle.api_core.gapic_v1importconfig_async
1725

‎tests/asyncio/gapic/test_method_async.py‎

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

1515
importdatetime
1616

17-
fromgrpcimportaio
1817
importmock
1918
importpytest
2019

20+
try:
21+
fromgrpcimportaio
22+
exceptImportError:
23+
pytest.skip("No GRPC",allow_module_level=True)
24+
2125
fromgoogle.api_coreimportexceptions
2226
fromgoogle.api_coreimportgapic_v1
2327
fromgoogle.api_coreimportgrpc_helpers_async

‎tests/asyncio/operations_v1/test_operations_async_client.py‎

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

15-
fromgrpcimportaio
1615
importmock
1716
importpytest
1817

19-
fromgoogle.api_coreimportgrpc_helpers_async,operations_v1,page_iterator_async
18+
try:
19+
fromgrpcimportaio
20+
exceptImportError:
21+
pytest.skip("No GRPC",allow_module_level=True)
22+
23+
fromgoogle.api_coreimportgrpc_helpers_async
24+
fromgoogle.api_coreimportoperations_v1
25+
fromgoogle.api_coreimportpage_iterator_async
2026
fromgoogle.longrunningimportoperations_pb2
2127
fromgoogle.protobufimportempty_pb2
2228

‎tests/asyncio/test_grpc_helpers_async.py‎

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

15-
importgrpc
16-
fromgrpcimportaio
1715
importmock
18-
importpytest
16+
importpytest# noqa: I202
17+
18+
try:
19+
importgrpc
20+
fromgrpcimportaio
21+
exceptImportError:
22+
grpc=aio=None
23+
24+
25+
ifgrpcisNone:
26+
pytest.skip("No GRPC",allow_module_level=True)
27+
1928

2029
fromgoogle.api_coreimportexceptions
2130
fromgoogle.api_coreimportgrpc_helpers_async

‎tests/asyncio/test_operation_async.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
importmock
1717
importpytest
1818

19+
try:
20+
importgrpc# noqa: F401
21+
exceptImportError:
22+
pytest.skip("No GRPC",allow_module_level=True)
23+
1924
fromgoogle.api_coreimportexceptions
2025
fromgoogle.api_coreimportoperation_async
2126
fromgoogle.api_coreimportoperations_v1

‎tests/unit/gapic/test_client_info.py‎

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

15+
importpytest
16+
17+
try:
18+
importgrpc# noqa: F401
19+
exceptImportError:
20+
pytest.skip("No GRPC",allow_module_level=True)
21+
1522

1623
fromgoogle.api_core.gapic_v1importclient_info
1724

‎tests/unit/gapic/test_config.py‎

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

15+
importpytest
16+
17+
try:
18+
importgrpc# noqa: F401
19+
exceptImportError:
20+
pytest.skip("No GRPC",allow_module_level=True)
21+
1522
fromgoogle.api_coreimportexceptions
1623
fromgoogle.api_core.gapic_v1importconfig
1724

‎tests/unit/gapic/test_method.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@
1515
importdatetime
1616

1717
importmock
18+
importpytest
19+
20+
try:
21+
importgrpc# noqa: F401
22+
exceptImportError:
23+
pytest.skip("No GRPC",allow_module_level=True)
24+
1825

1926
fromgoogle.api_coreimportexceptions
2027
fromgoogle.api_coreimportretry

‎tests/unit/gapic/test_routing_header.py‎

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

15+
importpytest
16+
17+
try:
18+
importgrpc# noqa: F401
19+
exceptImportError:
20+
pytest.skip("No GRPC",allow_module_level=True)
21+
1522

1623
fromgoogle.api_core.gapic_v1importrouting_header
1724

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp