3636# 'docfx' is excluded since it only needs to run in 'docs-presubmit'
3737nox .options .sessions = [
3838 "unit" ,
39- "unit_grpc_gcp" ,
40- "unit_wo_grpc" ,
41- "unit_w_prerelease_deps" ,
42- "unit_w_async_rest_extra" ,
39+ "prerelease_deps" ,
4340 "cover" ,
44- "pytype" ,
45- "mypy" ,
4641 "lint" ,
4742 "lint_setup_py" ,
4843 "blacken" ,
@@ -70,6 +65,17 @@ def lint(session):
7065 )
7166 session .run ("flake8" , "google" , "tests" )
7267
68+ """Run type-checking."""
69+ session .install (".[grpc,async_rest]" , "mypy" )
70+ session .install (
71+ "types-setuptools" ,
72+ "types-requests" ,
73+ "types-protobuf" ,
74+ "types-dataclasses" ,
75+ "types-mock; python_version=='3.7'" ,
76+ )
77+ session .run ("mypy" , "google" , "tests" )
78+
7379
7480@nox .session (python = DEFAULT_PYTHON_VERSION )
7581def blacken (session ):
@@ -215,46 +221,41 @@ def default(session, install_grpc=True, prerelease=False, install_async_rest=Fal
215221
216222
217223@nox .session (python = PYTHON_VERSIONS )
218- def unit (session ):
224+ @nox .parametrize (
225+ ["install_grpc_gcp" , "install_grpc" , "install_async_rest" ],
226+ [
227+ (False , True , False ), # Run unit tests with grpcio installed
228+ (True , True , False ), # Run unit tests with grpcio/grpcio-gcp installed
229+ (False , False , False ), # Run unit tests without grpcio installed
230+ (False , True , True ), # Run unit tests with grpcio and async rest installed
231+ ],
232+ )
233+ def unit (session , install_grpc_gcp , install_grpc , install_async_rest ):
219234 """Run the unit test suite."""
220- default (session )
221-
222235
223- @ nox . session ( python = PYTHON_VERSIONS )
224- def unit_w_prerelease_deps ( session ):
225- """Run the unit test suite."""
226- default ( session , prerelease = True )
227-
228-
229- @ nox . session ( python = PYTHON_VERSIONS )
230- def unit_grpc_gcp ( session ):
231- """
232- Run the unit test suite with grpcio-gcp installed.
233- `grpcio-gcp` doesn't support protobuf 4+.
234- Remove extra `grpcgcp` when protobuf 3.x is dropped.
235- https://github.com/googleapis/python-api-core/issues/594
236- """
237- constraints_path = str (
238- CURRENT_DIRECTORY / "testing" / f"constraints- { session . python } .txt"
236+ # `grpcio-gcp` doesn't support protobuf 4+.
237+ # Remove extra `grpcgcp` when protobuf 3.x is dropped.
238+ # https://github.com/googleapis/python-api-core/issues/594
239+ if install_grpc_gcp :
240+ constraints_path = str (
241+ CURRENT_DIRECTORY / "testing" / f"constraints- { session . python } .txt"
242+ )
243+ # Install grpcio-gcp
244+ session . install ( "-e" , ".[grpcgcp]" , "-c" , constraints_path )
245+ # Install protobuf < 4.0.0
246+ session . install ( "protobuf<4.0.0" )
247+
248+ default (
249+ session = session ,
250+ install_grpc = install_grpc ,
251+ install_async_rest = install_async_rest ,
239252 )
240- # Install grpcio-gcp
241- session .install ("-e" , ".[grpcgcp]" , "-c" , constraints_path )
242- # Install protobuf < 4.0.0
243- session .install ("protobuf<4.0.0" )
244-
245- default (session )
246-
247-
248- @nox .session (python = PYTHON_VERSIONS )
249- def unit_wo_grpc (session ):
250- """Run the unit test suite w/o grpcio installed"""
251- default (session , install_grpc = False )
252253
253254
254- @nox .session (python = PYTHON_VERSIONS )
255- def unit_w_async_rest_extra (session ):
256- """Run the unit test suite with the `async_rest` extra """
257- default (session , install_async_rest = True )
255+ @nox .session (python = DEFAULT_PYTHON_VERSION )
256+ def prerelease_deps (session ):
257+ """Run the unit test suite. """
258+ default (session , prerelease = True )
258259
259260
260261@nox .session (python = DEFAULT_PYTHON_VERSION )
@@ -265,27 +266,6 @@ def lint_setup_py(session):
265266 session .run ("python" , "setup.py" , "check" , "--restructuredtext" , "--strict" )
266267
267268
268- @nox .session (python = DEFAULT_PYTHON_VERSION )
269- def pytype (session ):
270- """Run type-checking."""
271- session .install (".[grpc]" , "pytype" )
272- session .run ("pytype" )
273-
274-
275- @nox .session (python = DEFAULT_PYTHON_VERSION )
276- def mypy (session ):
277- """Run type-checking."""
278- session .install (".[grpc,async_rest]" , "mypy" )
279- session .install (
280- "types-setuptools" ,
281- "types-requests" ,
282- "types-protobuf" ,
283- "types-dataclasses" ,
284- "types-mock; python_version=='3.7'" ,
285- )
286- session .run ("mypy" , "google" , "tests" )
287-
288-
289269@nox .session (python = DEFAULT_PYTHON_VERSION )
290270def cover (session ):
291271 """Run the final coverage report.
0 commit comments