From 497ebb03b5d6e34f9584e78b6da39cddd855254b Mon Sep 17 00:00:00 2001 From: Charlie Denton Date: Wed, 4 Jan 2023 00:06:38 +0000 Subject: [PATCH] Don't count protocols in test coverage --- cbv/importer/importers.py | 2 +- pyproject.toml | 4 ++++ tests/test_views.py | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cbv/importer/importers.py b/cbv/importer/importers.py index 8a304b34..9e77120f 100644 --- a/cbv/importer/importers.py +++ b/cbv/importer/importers.py @@ -27,7 +27,7 @@ ) -class CodeImporter(Protocol): +class CodeImporter(Protocol): # nocoverage: protocol def generate_code_data(self) -> Iterator[CodeElement]: ... diff --git a/pyproject.toml b/pyproject.toml index 7cec06a4..a3a18464 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,6 +11,10 @@ dynamic_context = "test_function" [tool.coverage.report] show_missing = true skip_covered = true +exclude_lines = [ + # Protocol classes are abstract, and don't need coverage. + "nocoverage: protocol", +] [tool.coverage.html] show_contexts = true diff --git a/tests/test_views.py b/tests/test_views.py index b2a0e94d..352372d1 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -9,7 +9,7 @@ from .factories import KlassFactory, ProjectVersionFactory -class AssertNumQueriesFixture(Protocol): +class AssertNumQueriesFixture(Protocol): # nocoverage: protocol def __call__(self, num: int, exact: bool = True) -> CaptureQueriesContext: ...