Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,30 @@ def cover(session):
def default(session, path):
# Install all test dependencies, then install this package in-place.
session.install("-r", "requirements-test.txt")
session.install("-e", ".")
session.install(".")
session.install("-r", "requirements.txt")
# Run pytest with coverage.
# Using the coverage command instead of `pytest --cov`, because
# `pytest ---cov` causes the module to be initialized twice, which returns
# this error: "ImportError: PyO3 modules compiled for CPython 3.8 or older
# may only be initialized once per interpreter process". More info about
# this is stated here: https://github.com/pytest-dev/pytest-cov/issues/614.
session.run(
"coverage",
"run",
"--include=*/google/cloud/alloydb/connector/*.py",
"-m",
"pytest",
"--cov=google.cloud.alloydb.connector",
"-v",
"--cov-config=.coveragerc",
"--cov-report=",
"--cov-fail-under=0",
"--junitxml=sponge_log.xml",
path,
*session.posargs,
)
session.run(
"coverage",
"xml",
"-o",
"sponge_log.xml",
)


@nox.session(python=UNIT_TEST_PYTHON_VERSIONS)
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
"requests",
"google-auth",
"protobuf",
"google-cloud-alloydb",
"google-api-core",
]

package_root = os.path.abspath(os.path.dirname(__file__))
Expand Down
17 changes: 4 additions & 13 deletions tests/unit/test_packaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,20 @@


def test_namespace_package_compat(tmp_path: pathlib.PosixPath) -> None:
# The ``google`` namespace package should not be masked
# by the presence of ``google-cloud-alloydb-connector``.
# The ``google`` namespace package should not be masked by the presence of
# `google-cloud-alloydb` and ``google-cloud-alloydb-connector``.
google = tmp_path / "google"
google.mkdir()
google.joinpath("othermod.py").write_text("")
env = dict(os.environ, PYTHONPATH=str(tmp_path))
cmd = [sys.executable, "-m", "google.othermod"]
subprocess.check_call(cmd, env=env)

# The ``google.cloud`` namespace package should not be masked
# by the presence of ``google-cloud-alloydb-connector``.
# The ``google.cloud`` namespace package should not be masked by the presence of
# ``google-cloud-alloydb`` and ``google-cloud-alloydb-connector``.
google_cloud = tmp_path / "google" / "cloud"
google_cloud.mkdir()
google_cloud.joinpath("othermod.py").write_text("")
env = dict(os.environ, PYTHONPATH=str(tmp_path))
cmd = [sys.executable, "-m", "google.cloud.othermod"]
subprocess.check_call(cmd, env=env)

# The ``google.cloud.sql`` namespace package should not be masked
# by the presence of ``google-cloud-alloydb-connector``.
google_cloud_alloydb = tmp_path / "google" / "cloud" / "alloydb"
google_cloud_alloydb.mkdir()
google_cloud_alloydb.joinpath("othermod.py").write_text("")
env = dict(os.environ, PYTHONPATH=str(tmp_path))
cmd = [sys.executable, "-m", "google.cloud.alloydb.othermod"]
subprocess.check_call(cmd, env=env)
Loading