From 5f874c74318a4d7e6a69c450bf120ca8a7b391a4 Mon Sep 17 00:00:00 2001 From: evilchili Date: Sat, 19 Nov 2022 17:23:47 -0800 Subject: [PATCH] adding test coverage reports --- .coveragerc | 26 ++++++++++++++++++++++++++ groove/auth.py | 5 ++++- pyproject.toml | 1 + pytest.ini | 3 +-- 4 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..b676257 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,26 @@ +# .coveragerc to control coverage.py +[run] +branch = True + +[report] +# Regexes for lines to exclude from consideration +exclude_lines = + # 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 + +ignore_errors = True diff --git a/groove/auth.py b/groove/auth.py index 2d134ea..0f58299 100644 --- a/groove/auth.py +++ b/groove/auth.py @@ -2,6 +2,9 @@ import logging import os -def is_authenticated(username, password): +def is_authenticated(username: str, password: str) -> bool: + """ + Returns True if the supplied username/password matches the environment. + """ logging.debug(f"Authentication attempt for {username}, {password}") return (username == os.environ.get('USERNAME') and password == os.environ.get('PASSWORD')) diff --git a/pyproject.toml b/pyproject.toml index 80771c7..88b33f8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,6 +21,7 @@ pytest-asyncio = "^0.20.2" pytest-dotenv = "^0.5.2" boddle = "^0.2.9" atheris = "^2.1.1" +pytest-cov = "^4.0.0" [build-system] requires = ["poetry-core>=1.0.0"] diff --git a/pytest.ini b/pytest.ini index 4daee8e..af41aee 100644 --- a/pytest.ini +++ b/pytest.ini @@ -2,5 +2,4 @@ env_override_existing_values = 1 env_files = .test_env log_cli_level = DEBUG - - +addopts = --cov=groove/ --cov-report=term