Skip to content

Commit fc844ad

Browse files
committed
consolidate unit test test sessions
1 parent c3e3ad3 commit fc844ad

File tree

1 file changed

+29
-36
lines changed

1 file changed

+29
-36
lines changed

packages/google-api-core/noxfile.py

Lines changed: 29 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from __future__ import absolute_import
1616
import os
1717
import pathlib
18+
import pytest
1819
import re
1920
import shutil
2021
import unittest
@@ -44,10 +45,7 @@
4445
# 'docfx' is excluded since it only needs to run in 'docs-presubmit'
4546
nox.options.sessions = [
4647
"unit",
47-
"unit_grpc_gcp",
48-
"unit_wo_grpc",
4948
"prerelease_deps",
50-
"unit_w_async_rest_extra",
5149
"cover",
5250
"pytype",
5351
"mypy",
@@ -222,10 +220,36 @@ def default(session, install_grpc=True, prerelease=False, install_async_rest=Fal
222220
session.run(*pytest_args)
223221

224222

223+
@pytest.mark.parametrize(
224+
"install_grpc_gcp,install_grpc,install_async_rest",
225+
[
226+
(False, True, False), # Run unit tests with grpcio installed
227+
(True, True, False), # Run unit tests with grpcio/grpcio-gcp installed
228+
(False, False, False), # Run unit tests without grpcio installed
229+
(False, True, True), # Run unit tests with grpcio and async rest installed
230+
],
231+
)
225232
@nox.session(python=PYTHON_VERSIONS)
226-
def unit(session):
233+
def unit(session, install_grpc_gcp, install_grpc, install_async_rest):
227234
"""Run the unit test suite."""
228-
default(session)
235+
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,
252+
)
229253

230254

231255
@nox.session(python=PYTHON_VERSIONS)
@@ -234,37 +258,6 @@ def prerelease_deps(session):
234258
default(session, prerelease=True)
235259

236260

237-
@nox.session(python=PYTHON_VERSIONS)
238-
def unit_grpc_gcp(session):
239-
"""
240-
Run the unit test suite with grpcio-gcp installed.
241-
`grpcio-gcp` doesn't support protobuf 4+.
242-
Remove extra `grpcgcp` when protobuf 3.x is dropped.
243-
https://github.com/googleapis/python-api-core/issues/594
244-
"""
245-
constraints_path = str(
246-
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
247-
)
248-
# Install grpcio-gcp
249-
session.install("-e", ".[grpcgcp]", "-c", constraints_path)
250-
# Install protobuf < 4.0.0
251-
session.install("protobuf<4.0.0")
252-
253-
default(session)
254-
255-
256-
@nox.session(python=PYTHON_VERSIONS)
257-
def unit_wo_grpc(session):
258-
"""Run the unit test suite w/o grpcio installed"""
259-
default(session, install_grpc=False)
260-
261-
262-
@nox.session(python=PYTHON_VERSIONS)
263-
def unit_w_async_rest_extra(session):
264-
"""Run the unit test suite with the `async_rest` extra"""
265-
default(session, install_async_rest=True)
266-
267-
268261
@nox.session(python=DEFAULT_PYTHON_VERSION)
269262
def lint_setup_py(session):
270263
"""Verify that setup.py is valid (including RST check)."""

0 commit comments

Comments
 (0)