Skip to content
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

chore: added a make command to run code coverage #182

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ dist/
.idea/
.env
~*
.vscode/launch.json
.vscode/launch.json
coverage.xml
.coverage
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ format: install
test: install
poetry run nox -s test $(if $(PYTHON),--python=$(PYTHON),)

coverage: install
poetry run nox -s coverage

help:
@echo '===================='
@echo 'build - build the library'
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,14 @@ Run unit tests for the specific python version:
make test PYTHON=3.11
```

## Code coverage

Run code coverage:

```sh
make coverage
```

## Clean

To remove the virtual environment and build artifacts run:
Expand Down
13 changes: 13 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ def format(session: nox.Session):
format_with_args(session, SRC)


@nox.session
def coverage(session: nox.Session) -> None:
"""Run tests and generate coverage report"""
session.run("poetry", "install", external=True)
session.run(
"pytest",
f"--cov={SRC}",
"--cov-report=xml",
"--cov-report=term",
)
session.run("coverage", "html", "--data-file=.coverage")


@nox.session(python=["3.8", "3.9", "3.10", "3.11", "3.12"])
# Testing against earliest and latest supported versions of the dependencies
@nox.parametrize("pydantic", ["1.10.17", "2.8.2"])
Expand Down
107 changes: 106 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ telemetry = [
[tool.poetry.group.test.dependencies]
pytest = "^8.2"
pytest-asyncio = "^0.24.0"
pytest-cov = "^5.0.0"
nox = "^2023.4.22"
pillow = "^10.2.0"
respx = "^0.21.1"
Expand All @@ -73,6 +74,19 @@ testpaths = [
"tests"
]

[tool.coverage.run]
branch = true
source = ["."]
omit = [
"tests/*",
"examples/*",
"*/__init__.py",
"noxfile.py"
]

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

[tool.pyright]
typeCheckingMode = "basic"
reportUnusedVariable = "error"
Expand Down
Loading