From 353a7a8a74a6c3aa552c21e8017b9e5629a7981e Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Sat, 20 Apr 2024 12:42:08 -0400 Subject: [PATCH] tests: add tests for hatch env (#33) * tests: add tests for hatch env Signed-off-by: Henry Schreiner * style: pre-commit fixes --------- Signed-off-by: Henry Schreiner Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- pyproject.toml | 1 + tests/test_validate_pyproject.py | 35 +++++++++++++++++++++++++------- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 04fe1b3..72060a5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,6 +37,7 @@ test = [ "pytest >=6", "pytest-cov >=3", "validate-pyproject>=0.16", + "tomli; python_version<'3.11'", ] docs = [ "sphinx>=7.0", diff --git a/tests/test_validate_pyproject.py b/tests/test_validate_pyproject.py index c8c2027..a40a53f 100644 --- a/tests/test_validate_pyproject.py +++ b/tests/test_validate_pyproject.py @@ -1,19 +1,40 @@ from __future__ import annotations +import sys + from validate_pyproject import api +if sys.version_info < (3, 11): + import tomli as tomllib +else: + import tomllib + def test_vpp_loads(caplog): - pyproject_as_dict = { - "tool": { - "ruff": { - "src": ["src"], - } - } - } + pyproject_as_dict = tomllib.loads(""" + [tool.ruff] + src = ["src"] + """) + validator = api.Validator() validator(pyproject_as_dict) assert ( "validate_pyproject_schema_store.schema.get_schema defines `tool.poetry` schema" in caplog.text ) + + +def test__loads(caplog): + pyproject_as_dict = tomllib.loads(""" + [tool.hatch.env] + requires = [ + "hatch-pip-compile" + ] + """) + + validator = api.Validator() + validator(pyproject_as_dict) + assert ( + "validate_pyproject_schema_store.schema.get_schema defines `tool.hatch` schema" + in caplog.text + )