Skip to content
This repository was archived by the owner on Jan 13, 2026. It is now read-only.

Commit 9e03690

Browse files
committed
Fix coverage reporting across Python versions
1 parent 2256fdf commit 9e03690

File tree

6 files changed

+31
-11
lines changed

6 files changed

+31
-11
lines changed

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,10 @@ coverage: python
4242
pyenv exec tox -e coverage
4343

4444
.PHONY: sure
45-
sure: checkformatting lint test coverage functests
45+
sure: checkformatting lint test functests
4646
pyenv exec tox -e py39-tests
4747
pyenv exec tox -e py38-tests
48+
pyenv exec tox -e coverage
4849
pyenv exec tox -e py39-functests
4950
pyenv exec tox -e py38-functests
5051

@@ -54,7 +55,7 @@ requirements:
5455

5556
.PHONY: clean
5657
clean:
57-
rm -rf build dist .tox
58+
rm -rf build dist .coverage .tox
5859
find . -path '*/__pycache__*' -delete
5960
find . -path '*.egg-info*' -delete
6061

pyproject.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22
requires = ["setuptools>=42"]
33
build-backend = "setuptools.build_meta"
44

5+
[tool.coverage.run]
6+
branch = true
7+
parallel = true
8+
source = ["python_multiversion_dependency_management_demo", "tests/unit"]
9+
10+
[tool.coverage.paths]
11+
source = ["src", ".tox/*/site-packages"]
12+
13+
[tool.coverage.report]
14+
show_missing = true
15+
precision = 2
16+
fail_under = 100.00
17+
skip_covered = true
18+
519
[tool.pydocstyle]
620
ignore = [
721
# Missing docstrings.
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1+
import sys
2+
13
from flask import Flask
24

35
app = Flask(__name__)
46

57

68
@app.route("/")
79
def hello_world():
8-
return "<p>Hello, World!</p>"
10+
if sys.version.startswith("3.9"):
11+
return "<p>Hello, Python 3.9!</p>"
12+
13+
if sys.version.startswith("3.8"):
14+
return "<p>Hello, Python 3.8!</p>"
15+
16+
return "<p>Hello, Python!</p>"

tests/functional/app_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ def client():
1111
def test_request_example(client):
1212
response = client.get("/")
1313

14-
assert b"<p>Hello, World!</p>" in response.data
14+
assert b"<p>Hello, Python" in response.data

tests/unit/python_multiversion_dependency_management_demo/app_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33

44
def test_it():
5-
assert hello_world() == "<p>Hello, World!</p>"
5+
assert hello_world().startswith("<p>Hello, Python")

tox.ini

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
[tox]
22
envlist = py310-tests
3-
skipsdist = true
43
minversion = 3.25.0
54
requires =
65
tox-pyenv
@@ -9,10 +8,10 @@ tox_pyenv_fallback = false
98
isolated_build = true
109

1110
[testenv]
12-
skip_install = true
1311
recreate = true
12+
skip_install =
13+
{format,checkformatting,coverage}: true
1414
setenv =
15-
PYTHONPATH = src
1615
FLASK_APP = python_multiversion_dependency_management_demo.app
1716
deps =
1817
lint: -r requirements/py310/lint.txt
@@ -27,8 +26,6 @@ deps =
2726
py38-dev: -r requirements/py38/dev.txt
2827
py38-tests: -r requirements/py38/tests.txt
2928
py38-functests: -r requirements/py38/functests.txt
30-
depends =
31-
coverage: tests
3229
commands =
3330
dev: flask run --port 5482
3431
lint: pylint src bin
@@ -41,5 +38,5 @@ commands =
4138
checkformatting: isort --quiet --check-only src tests bin
4239
tests: coverage run -m pytest -v {posargs:tests/unit/}
4340
functests: pytest {posargs:tests/functional/}
44-
coverage: -coverage combine
41+
coverage: coverage combine
4542
coverage: coverage report

0 commit comments

Comments
 (0)