Skip to content

Commit

Permalink
CI(pyavd): Ignore Jinja generated instructions from coverage (#3451)
Browse files Browse the repository at this point in the history
  • Loading branch information
gmuloc authored Dec 21, 2023
1 parent 78e40c3 commit 0f73e76
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 13 deletions.
35 changes: 35 additions & 0 deletions python-avd/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,38 @@ profile = "black"
skip_gitignore = true
line_length = 160
known_third_party = ["pyavd"]

[tool.coverage.run]
branch = true

[tool.coverage.report]
show_missing = true
fail_under = 89
include = [
"pyavd/*"
]
# Regexes for lines to exclude from consideration
exclude_also = [
# Have to re-enable the standard pragma
"pragma: no cover",
# Don't complain about missing debug-only code:
"def __repr__",
"if self\\.debug",
# Don't complain if tests don't hit defensive assertion code:
"raise AssertionError",
"raise NotImplementedError",
# Don't complain if non-runnable code isn't run:
"if 0:",
"if __name__ == .__main__.:",
# Don't complain about abstract methods, they aren't run:
"@(abc\\.)?abstractmethod",
# Don't complain about TYPE_CHECKING blocks
"if TYPE_CHECKING:",
# Dont' complain about Jinja2 internalcode
# Note that except KeyError is a bit sad but this is the pattern
"except KeyError:",
"@internalcode",
"raise TemplateRuntimeError",
"^blocks = {}",
"^debug_info =.*",
]
22 changes: 9 additions & 13 deletions python-avd/tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,25 @@ deps =
extras = mdtoc
commands =
make test-dep
pytest
# posargs allows to run only a specific test using
# tox -e <env> -- path/to/my/test::test
pytest {posargs}

[testenv:coverage]
deps =
pytest
PyYAML>=6.0.0
pydantic>=2.3.0
coverage
coverage[toml]
commands =
coverage erase
coverage run -m pytest
# posargs allows to run only a specific test using
# tox -e <env> -- path/to/my/test::test
coverage run --rcfile=pyproject.toml -m pytest {posargs}

[testenv:report]
skip_install = true
deps =
coverage
coverage[toml]
commands =
coverage report

[coverage:report]
fail_under = 85
show_missing = true
include =
pyavd/*
exclude_also =
raise NotImplementedError
coverage report --rcfile=pyproject.toml

0 comments on commit 0f73e76

Please sign in to comment.