Skip to content

PYTHON-3987 Enable coverage relative_files=true and use pyproject.toml #1406

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 24, 2023
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
25 changes: 0 additions & 25 deletions .coveragerc

This file was deleted.

3 changes: 2 additions & 1 deletion .evergreen/combine-coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ fi

createvirtualenv "$PYTHON_BINARY" covenv
# coverage 7.3 dropped support for Python 3.7, keep in sync with run-tests.sh
pip install -q "coverage<7.3"
# coverage >=5 is needed for relative_files=true.
pip install -q "coverage>=5,<7.3"

pip list
ls -la coverage/
Expand Down
3 changes: 2 additions & 1 deletion .evergreen/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ python -c 'import sys; print(sys.version)'
PYTHON_IMPL=$($PYTHON -c "import platform; print(platform.python_implementation())")
if [ -n "$COVERAGE" ] && [ "$PYTHON_IMPL" = "CPython" ]; then
# coverage 7.3 dropped support for Python 3.7, keep in sync with combine-coverage.sh.
python -m pip install pytest-cov "coverage<7.3"
# coverage >=5 is needed for relative_files=true.
python -m pip install pytest-cov "coverage>=5,<7.3"
TEST_ARGS="$TEST_ARGS --cov pymongo --cov-branch --cov-report term-missing:skip-covered"
fi

Expand Down
22 changes: 22 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,25 @@ dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?)|dummy.*)$"
"RET", "ARG", "F405", "B028", "PGH001", "B018", "F403", "RUF015", "E731", "B007",
"UP031", "F401", "B023", "F811"]
"green_framework_test.py" = ["T201"]

[tool.coverage.run]
branch = true
source = ["pymongo", "bson", "gridfs" ]
relative_files = true

[tool.coverage.report]
exclude_lines = [
"if (.*and +)*_use_c( and.*)*:",
"def has_c",
"def get_version_string",
"^except AttributeError:",
"except ImportError:",
"raise NotImplementedError",
"return NotImplemented",
"_use_c = true",
"if __name__ == '__main__':",
]
partial_branches = ["if (.*and +)*not _use_c( and.*)*:"]

[tool.coverage.html]
directory = "htmlcov"