Skip to content

Commit 8373ded

Browse files
Modify pytest coverage to use coverage command instead
1 parent 345679e commit 8373ded

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

noxfile.py

+15-5
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,27 @@ def default(session, path):
129129
session.install(".")
130130
session.install("-r", "requirements.txt")
131131
# Run pytest with coverage.
132+
# Using the coverage command instead of `pytest --cov`, because
133+
# `pytest ---cov` causes the module to be initialized twice, which returns
134+
# this error: "ImportError: PyO3 modules compiled for CPython 3.8 or older
135+
# may only be initialized once per interpreter process". More info about
136+
# this is stated here: https://github.com/pytest-dev/pytest-cov/issues/614.
132137
session.run(
138+
"coverage",
139+
"run",
140+
"--include=*/google/cloud/alloydb/connector/*.py",
141+
"-m",
133142
"pytest",
134-
"--cov=google.cloud.alloydb.connector",
135143
"-v",
136-
"--cov-config=.coveragerc",
137-
"--cov-report=",
138-
"--cov-fail-under=0",
139-
"--junitxml=sponge_log.xml",
140144
path,
141145
*session.posargs,
142146
)
147+
session.run(
148+
"coverage",
149+
"xml",
150+
"-o",
151+
"sponge_log.xml",
152+
)
143153

144154

145155
@nox.session(python=UNIT_TEST_PYTHON_VERSIONS)

0 commit comments

Comments
 (0)