From 92ac49e39b76f2204c0fb15704b200a7630dc4e8 Mon Sep 17 00:00:00 2001 From: Marcel Wilson Date: Tue, 19 Mar 2024 17:54:39 -0500 Subject: [PATCH] adding coverage exclusions --- pyproject.toml | 7 +++++++ screenpy/configuration.py | 4 ++-- tests/test_actions.py | 2 +- tests/test_pacing.py | 6 +++--- tests/test_pacing_future.py | 6 +++--- tests/test_settings.py | 6 ++++-- 6 files changed, 20 insertions(+), 11 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d00e087..81988ba 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -234,3 +234,10 @@ playwright = ["screenpy-playwright"] pyotp = ["screenpy-pyotp"] requests = ["screenpy-requests"] selenium = ["screenpy-selenium"] + + +[tool.coverage.report] +exclude_also = [ + "if TYPE_CHECKING:", + "pass", +] diff --git a/screenpy/configuration.py b/screenpy/configuration.py index fca6a7e..8a738b1 100644 --- a/screenpy/configuration.py +++ b/screenpy/configuration.py @@ -17,14 +17,14 @@ from pydantic.fields import FieldInfo -if sys.version_info >= (3, 11): +if sys.version_info >= (3, 11): # pragma: no cover try: import tomllib except ImportError: if not TYPE_CHECKING: # Help users on older alphas import tomli as tomllib -else: +else: # pragma: no cover import tomli as tomllib diff --git a/tests/test_actions.py b/tests/test_actions.py index c310244..a8bf72d 100644 --- a/tests/test_actions.py +++ b/tests/test_actions.py @@ -1203,7 +1203,7 @@ def test_output_first_passes( ) -> None: class FakeActionFail(Performable): @beat("{} tries to FakeActionFail") - def perform_as(self, _: Actor) -> None: + def perform_as(self, _: Actor) -> None: # pragma: no cover msg = "This Fails!" raise AssertionError(msg) diff --git a/tests/test_pacing.py b/tests/test_pacing.py index 8f76665..a4d38e7 100644 --- a/tests/test_pacing.py +++ b/tests/test_pacing.py @@ -51,7 +51,7 @@ def do_not_log_me_man(self) -> None: @beat("Foobar...") def does_return_something(self, toggle: bool = False) -> Optional[int]: if toggle: - return 1 + return 1 # pragma: no cover return None # purposfully not annotated @@ -59,7 +59,7 @@ def does_return_something(self, toggle: bool = False) -> Optional[int]: # type: ignore[no-untyped-def] def no_annotations_rt_none(self, toggle=False): # noqa: ANN001, ANN201 if toggle: - return 1 + return 1 # pragma: no cover return None # purposfully not annotated @@ -68,7 +68,7 @@ def no_annotations_rt_none(self, toggle=False): # noqa: ANN001, ANN201 def no_annotations_rt_int(self, toggle=False): # noqa: ANN001, ANN201 if toggle: return 1 - return None + return None # pragma: no cover def describe(self) -> str: return "CornerCase" diff --git a/tests/test_pacing_future.py b/tests/test_pacing_future.py index 44ac4f3..3b34a05 100644 --- a/tests/test_pacing_future.py +++ b/tests/test_pacing_future.py @@ -29,7 +29,7 @@ def do_not_log_me_man(self) -> None: @beat("Foobar...") def does_return_something(self, toggle: bool = False) -> int | None: if toggle: - return 1 + return 1 # pragma: no cover return None # purposfully not annotated @@ -37,7 +37,7 @@ def does_return_something(self, toggle: bool = False) -> int | None: # type: ignore[no-untyped-def] def no_annotations_rt_none(self, toggle=False): # noqa: ANN001, ANN201 if toggle: - return 1 + return 1 # pragma: no cover return None # purposfully not annotated @@ -46,7 +46,7 @@ def no_annotations_rt_none(self, toggle=False): # noqa: ANN001, ANN201 def no_annotations_rt_int(self, toggle=False): # noqa: ANN001, ANN201 if toggle: return 1 - return None + return None # pragma: no cover def describe(self) -> str: return "CornerCase" diff --git a/tests/test_settings.py b/tests/test_settings.py index 3239ff8..f8b5a6f 100644 --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os from pathlib import Path from unittest import mock @@ -69,7 +71,7 @@ def test_init_overwrites_env(self) -> None: def test_can_be_changed_at_runtime(self) -> None: try: screenpy_settings.TIMEOUT = 4 - except TypeError as exc: + except TypeError as exc: # pragma: no cover msg = "ScreenPySettings could not be changed at runtime." raise AssertionError(msg) from exc @@ -108,7 +110,7 @@ def test_init_overwrites_env(self) -> None: def test_can_be_changed_at_runtime(self) -> None: try: stdout_adapter_settings.INDENT_CHAR = "?" - except TypeError as exc: + except TypeError as exc: # pragma: no cover msg = "StdOutAdapterSettings could not be changed at runtime." raise AssertionError(msg) from exc