chore: setup example for pytest

This commit is contained in:
张泊明518370910136 2024-10-17 05:46:20 -04:00
parent 97a51af7cf
commit 4f4f0fb3f5
GPG Key ID: D47306D7062CDA9D
4 changed files with 33 additions and 1 deletions

View File

@ -31,6 +31,8 @@ repos:
rev: 1.7.10
hooks:
- id: bandit
args: [-c, pyproject.toml]
additional_dependencies: ['bandit[toml]']
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
@ -45,3 +47,11 @@ repos:
hooks:
- id: remove-crlf
- id: remove-tabs
- repo: local
hooks:
- id: pytest-check
name: pytest-check
entry: pytest
language: system
pass_filenames: false
always_run: true

View File

@ -16,3 +16,9 @@ source env/bin/activate
pip3 install ".[dev]"
pre-commit install
```
Run tests
```bash
pytest -svv
```

View File

@ -13,4 +13,8 @@ description = "config generator for joj3"
readme = "README.md"
[project.optional-dependencies]
dev = ["pre-commit>=3.7.1", "black>=24.4.2"]
dev = ["pre-commit>=3.7.1", "black>=24.4.2", "pytest>=8.3.3"]
[tool.bandit]
exclude_dirs = ["tests"]
skips = ["B101"]

12
tests/example_test.py Normal file
View File

@ -0,0 +1,12 @@
# from xxx import generate
from typing import Any
def test_generate() -> None:
generate = lambda x: x # TODO: real generate function imported
data_input: dict[Any, Any] = {} # TODO: load real input from some file
data_output: dict[Any, Any] = generate(data_input)
expected_output: dict[Any, Any] = {} # TODO: load real output from some file
assert data_output == expected_output