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 0eb4277 commit 7014274
Show file tree
Hide file tree
Showing 5 changed files with 192 additions and 207 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 7014274

Please sign in to comment.