From f634896ebc0f7dcd8f1e886d9c2cb9c35d73a498 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Paduszyn=CC=81ski?= Date: Thu, 2 Nov 2023 13:13:42 +0100 Subject: [PATCH 1/5] =?UTF-8?q?=E2=9E=95=20Add=20`pytest`=20and=20common?= =?UTF-8?q?=20plugins?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index b11f8c2..5a293c7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,6 +20,12 @@ lint = [ "mypy", "ruff", ] +test = [ + "pytest", + "pytest-cov", + "pytest-custom-exit-code", + "pytest-mock", +] [tool.setuptools.packages.find] include = ["gitmojis*"] From 52929bbd8fd56652151ad16777ceed012f675a9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Paduszyn=CC=81ski?= Date: Thu, 2 Nov 2023 13:16:26 +0100 Subject: [PATCH 2/5] =?UTF-8?q?=F0=9F=94=A7=20Configure=20Pytest=20and=20C?= =?UTF-8?q?overage.py=20in=20`pyproject.toml`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 5a293c7..804ee4c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -87,3 +87,39 @@ convention = "google" [tool.ruff.isort] known-first-party = ["gitmojis"] + +# Pytest +# https://docs.pytest.org/en/latest/reference/reference.html#configuration-options + +[tool.pytest.ini_options] +addopts = [ + "-ra", + "-q", + "--strict-markers", + "--cov=src/", + "--cov-branch", + "--cov-append", + "--cov-report=term-missing:skip-covered", + "--cov-report=xml", + "--suppress-no-test-exit-code", +] +pythonpath = [".", "src"] +testpaths = ["tests/"] + +# Coverage.py +# https://coverage.readthedocs.io/en/latest/config.html + +[tool.coverage.report] +exclude_also = [ + "@(abc\\.)?abstractmethod", + "@overload", + "class .*\\bProtocol\\):", + "def __repr__", + "if __name__ == .__main__.:", + "if 0:", + "if self.debug:", + "if settings.DEBUG", + "if TYPE_CHECKING:", + "raise AssertionError", + "raise NotImplementedError", +] From 992d0863781441c3a06700f319ff923ea4278c2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Paduszyn=CC=81ski?= Date: Thu, 2 Nov 2023 13:16:49 +0100 Subject: [PATCH 3/5] =?UTF-8?q?=F0=9F=94=A7=20Add=20`flake8-pytest-style`?= =?UTF-8?q?=20to=20the=20Ruff's=20rules?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 804ee4c..04ebbbd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -77,10 +77,11 @@ select = [ "A", # flake8-builtins "C4", # flake8-comprehensions "T20", # flake8-print + "PT", # flake8-pytest-style "Q", # flake8-quotes "PTH", # flake8-use-pathlib ] -ignore = ["E501", "N818", "D1", "D205"] +ignore = ["E501", "N818", "D1", "D205", "PT004", "PT016"] [tool.ruff.pydocstyle] convention = "google" From 384bcc793d493688b660597af675b239da9a36f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Paduszyn=CC=81ski?= Date: Thu, 2 Nov 2023 13:17:31 +0100 Subject: [PATCH 4/5] =?UTF-8?q?=F0=9F=94=A7=20Add=20`name-tests-test`=20to?= =?UTF-8?q?=20Pre-commit=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .pre-commit-config.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f2d3e9a..91e3af9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -6,6 +6,10 @@ repos: - id: check-toml - id: check-yaml - id: end-of-file-fixer + - id: name-tests-test + files: (tests) + args: + - --pytest-test-first - id: trailing-whitespace - repo: https://github.com/psf/black rev: '23.10.1' From 2dbb1ad76578cc72ee02bc0c7ab1420769094cc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Paduszyn=CC=81ski?= Date: Thu, 2 Nov 2023 13:20:28 +0100 Subject: [PATCH 5/5] =?UTF-8?q?=F0=9F=99=88=20Exclude=20Pytest=20cache=20a?= =?UTF-8?q?nd=20coverage=20report=20files=20from=20version=20control?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.gitignore b/.gitignore index 3193773..39ee305 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,10 @@ dist/ # Ruff .ruff_cache/ + +# Pytest +.pytest_cache/ + +# Coverage +.coverage +coverage.xml