Skip to content

Commit 41d393e

Browse files
committed
Add coverage support for unittests
1 parent 14588fb commit 41d393e

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ ignore_errors = true
6565
module = ["graphviz", "invoke.*"]
6666
ignore_missing_imports = true
6767

68+
[tool.coverage.run]
69+
source = ["lib/rule_engine"]
70+
omit = ["lib/rule_engine/_vendor/*"]
71+
72+
[tool.coverage.report]
73+
show_missing = true
74+
6875
[tool.setuptools]
6976
package-dir = {"" = "lib"}
7077

tasks.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@ def docs(c):
2323
c.run('uv run sphinx-build -b html -a -E -v docs/source docs/html')
2424

2525

26-
@task
27-
def tests(c):
26+
@task(help={'coverage': 'Measure test coverage and print a report.'})
27+
def tests(c, coverage=False):
2828
"""Run unit tests."""
29-
c.run('uv run python -m unittest -v', pty=True)
29+
if coverage:
30+
c.run('uv run coverage run -m unittest -v', pty=True)
31+
c.run('uv run coverage report')
32+
else:
33+
c.run('uv run python -m unittest -v', pty=True)
3034

3135
@task
3236
def typechecks(c):

0 commit comments

Comments
 (0)