diff --git a/CHANGELOG.md b/CHANGELOG.md index efa82a2..115c93b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Adopted more `ruff` rules. +### Testing + +- Improved tox config. +- Now store `hypothesis` and `pytest` cache in `.cache` directory. + ## [6.0] - 2023-11-19 ### Added diff --git a/pyproject.toml b/pyproject.toml index e0305f3..67dc17c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -113,14 +113,26 @@ Tracker = "https://github.com/xymy/gethash/issues" path = "src/gethash/__init__.py" [tool.hatch.envs.default] -type = "virtual" path = ".venv" system-packages = true features = ["all", "docs", "lint", "test"] +[tool.hatch.envs.default.env-vars] +COVERAGE_FILE = "{root}{/}.coverage" +HYPOTHESIS_STORAGE_DIRECTORY = "{root}{/}.cache{/}hypothesis" + [tool.hatch.envs.default.scripts] -test = ["coverage erase", "python -m pytest {args}", "coverage report"] docs = "python {root}{/}docs{/}release.py {args}" +lint = [ + "black {root}{/}src {root}{/}tests", + "ruff {root}{/}src {root}{/}tests", + "mypy {root}{/}src {root}{/}tests", +] +test = [ + "coverage erase", + "python -m pytest -o cache_dir={root}{/}.cache{/}pytest --cov-report=html:{root}{/}htmlcov {args}", + "coverage report", +] [tool.black] line-length = 120 diff --git a/tox.ini b/tox.ini index 1ff31f7..6877f29 100644 --- a/tox.ini +++ b/tox.ini @@ -13,15 +13,27 @@ package = wheel wheel_build_env = .pkg [testenv:py3{9,10,11,12}] +pass_env = + PYTEST_* set_env = - COVERAGE_FILE = {env:COVERAGE_FILE:{envdir}{/}.coverage} + COVERAGE_FILE = {envdir}{/}.coverage + HYPOTHESIS_STORAGE_DIRECTORY = {envdir}{/}.cache{/}hypothesis extras = test commands = coverage erase - python -m pytest -v --cov-report=html:{envdir}{/}htmlcov {posargs} + python -m pytest -v -o cache_dir={envdir}{/}.cache{/}pytest \ + --cov-report=html:{envdir}{/}htmlcov {posargs} coverage report +[testenv:lint] +extras = + lint +commands = + black {toxinidir}{/}src {toxinidir}{/}tests + ruff --cache-dir={envdir}{/}.cache{/}ruff {toxinidir}{/}src {toxinidir}{/}tests + mypy --cache-dir={envdir}{/}.cache{/}mypy {toxinidir}{/}src {toxinidir}{/}tests + [testenv:docs] extras = docs @@ -37,7 +49,7 @@ package = editable system_site_packages = true [pytest] -addopts = --strict-markers --cov --cov-context=test --cov-report=html +addopts = --strict-markers --cov --cov-context=test filterwarnings = error ignore::DeprecationWarning