Skip to content

Commit

Permalink
Migrate existing tests to pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
bwt-sloanj committed Sep 24, 2024
1 parent 0be11f6 commit 31acae3
Show file tree
Hide file tree
Showing 6 changed files with 195 additions and 211 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'
python-version: "3.10"

- name: Install uv
uses: astral-sh/setup-uv@v3
Expand All @@ -30,4 +30,4 @@ jobs:
run: uvx --with pre-commit pre-commit run --all-files

- name: Run tests
run: uv run python -m unittest discover
run: uv run pytest
5 changes: 2 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: debug-statements
- id: name-tests-test
args: [--unittest]
- id: requirements-txt-fixer
args: ["--pytest-test-first"]

- repo: https://github.com/asottile/pyupgrade
rev: v3.17.0
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ A [pre-commit hook](https://pre-commit.com/) implementation of the Linux kernel

Uses Linux kernel `checkpatch.pl` to check for coding style errors in C code, Makefiles, etc.

See the docs for the script itself [here](https://docs.kernel.org/dev-tools/checkpatch.html)
See the docs for the script itself [here](https://docs.kernel.org/dev-tools/checkpatch.html).

### Custom configuration file

Expand Down
3 changes: 2 additions & 1 deletion checkpatch_hook/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ def pre_process_dir_config(self, dconfig: dict, config: dict) -> dict:
for key, value in self.magic_error_keys.items():
if key in dconfig and value in dconfig[key]:
if value not in config.keys():
raise RuntimeError(f"Unknown key {value} in {self.config_file_path}")
logger.error(f"Unknown key {value} in {self.config_file_path}")
sys.exit(1)
dconfig[key].extend(config[value])
dconfig[key].remove(value)
return dconfig
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ dependencies = [

[tool.uv]
dev-dependencies = [
"tox>=4.18.0",
"pytest>=8.3.2",
"coverage>=7.6.1",
"pytest-cov>=5.0.0",
]

[tool.pytest.ini_options]
addopts = "--cov=checkpatch_hook --cov-branch"

[build-system]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"
Expand Down
Loading

0 comments on commit 31acae3

Please sign in to comment.