From 451254447fd2ecb427b357351a6365c6e72f151c Mon Sep 17 00:00:00 2001 From: Ben Vincent Date: Sun, 17 May 2026 11:35:03 +1000 Subject: [PATCH] feat: add pytest pre-commit hook and tests scaffold (issue #162) - pyproject.toml with pytest>=8 in [dependency-groups.dev] so uv run --group dev pytest resolves without a global install - tests/__init__.py and tests/conftest.py skeleton referencing issue #162 - pre-commit local hook runs pytest tests/ on Python file changes; exit code 5 (no tests collected) is treated as success so commits are not blocked while the test suite is being built out --- .pre-commit-config.yaml | 9 +++++++++ pyproject.toml | 9 +++++++++ tests/__init__.py | 0 tests/conftest.py | 2 ++ 4 files changed, 20 insertions(+) create mode 100644 pyproject.toml create mode 100644 tests/__init__.py create mode 100644 tests/conftest.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a4922d6..7460332 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -31,6 +31,15 @@ repos: "-s", ] + - repo: local + hooks: + - id: pytest + name: Run unit tests + entry: bash -c 'uv run --group dev pytest tests/ -q; rc=$?; [ $rc -eq 5 ] && exit 0 || exit $rc' + language: system + types: [python] + pass_filenames: false + - repo: https://github.com/python-jsonschema/check-jsonschema rev: 0.37.2 hooks: diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..76677c9 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,9 @@ +[project] +name = "rpmbuilder" +version = "0.1.0" +requires-python = ">=3.11" + +[dependency-groups] +dev = [ + "pytest>=8", +] diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..fe2d9d4 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,2 @@ +# Tests for tools/build and tools/update-gh. +# See https://git.unkin.net/unkin/rpmbuilder/issues/162