Skip to content

Commit fbf2937

Browse files
authored
PYTHON-4002 No module named coverage.__main__ (#1398)
1 parent 1cbd192 commit fbf2937

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

.evergreen/combine-coverage.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
#
3+
# Coverage combine merges (and removes) all the coverage files and
4+
# generates a new .coverage file in the current directory.
5+
6+
set -o xtrace # Write all commands first to stderr
7+
set -o errexit # Exit the script with error if any of the commands fail
8+
9+
. .evergreen/utils.sh
10+
11+
if [ -z "$PYTHON_BINARY" ]; then
12+
PYTHON_BINARY=$(find_python3)
13+
fi
14+
15+
createvirtualenv "$PYTHON_BINARY" covenv
16+
# coverage 7.3 dropped support for Python 3.7, keep in sync with run-tests.sh
17+
pip install -q "coverage<7.3"
18+
19+
pip list
20+
ls -la coverage/
21+
22+
python -m coverage combine coverage/coverage.*
23+
python -m coverage html -d htmlcov

.evergreen/config.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,7 @@ functions:
131131
working_dir: "src"
132132
script: |
133133
${PREPARE_SHELL}
134-
set -o xtrace
135-
# Coverage combine merges (and removes) all the coverage files and
136-
# generates a new .coverage file in the current directory.
137-
ls -la coverage/
138-
/opt/python/3.7/bin/python3 -m coverage combine coverage/coverage.*
139-
/opt/python/3.7/bin/python3 -m coverage html -d htmlcov
134+
bash .evergreen/combine-coverage.sh
140135
# Upload the resulting html coverage report.
141136
- command: shell.exec
142137
params:

.evergreen/run-tests.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ python -c 'import sys; print(sys.version)'
258258
# Only cover CPython. PyPy reports suspiciously low coverage.
259259
PYTHON_IMPL=$($PYTHON -c "import platform; print(platform.python_implementation())")
260260
if [ -n "$COVERAGE" ] && [ "$PYTHON_IMPL" = "CPython" ]; then
261-
python -m pip install pytest-cov "coverage"
261+
# coverage 7.3 dropped support for Python 3.7, keep in sync with combine-coverage.sh.
262+
python -m pip install pytest-cov "coverage<7.3"
262263
TEST_ARGS="$TEST_ARGS --cov pymongo --cov-branch --cov-report term-missing:skip-covered"
263264
fi
264265

0 commit comments

Comments
 (0)