Skip to content

Commit

Permalink
tests: add some tests for validate-pyproject
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
  • Loading branch information
henryiii committed Apr 30, 2024
1 parent 498ede7 commit 8b04dc2
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 9 deletions.
8 changes: 7 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ repos:
files: src|tests
args: []
additional_dependencies:
["tomli", "pathspec", "importlib-resources", "pytest"]
[
"tomli",
"pathspec",
"importlib-resources",
"pytest",
"validate-pyproject",
]

- repo: https://github.com/henryiii/check-sdist
rev: "v0.1.3"
Expand Down
9 changes: 2 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ test = [
"pytest >=6",
"pytest-cov >=3",
"pyproject-hooks !=1.1.0",
]
dev = [
"check-sdist[test]",
"validate-pyproject >=0.16",
]
uv = [
"uv",
Expand All @@ -60,10 +58,7 @@ check-sdist = "check_sdist.schema:get_schema"

[tool.hatch]
version.path = "src/check_sdist/__init__.py"
envs.default.dependencies = [
"pytest",
"pytest-cov",
]
envs.default.features = ["test"]


[tool.pytest.ini_options]
Expand Down
1 change: 0 additions & 1 deletion src/check_sdist/schema.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import annotations

import json
from pathlib import Path
from typing import Any

from .resources import resources
Expand Down
45 changes: 45 additions & 0 deletions tests/test_validate_pyproject.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from __future__ import annotations

import pytest
import validate_pyproject.api


def test_validate_pyproject_defaults():
example = {
"tool": {
"check-sdist": {
"sdist-only": [],
"git-only": [],
"default-ignore": True,
"recurse-submodules": True,
}
}
}
validator = validate_pyproject.api.Validator()
assert validator(example) is not None


def test_validate_pyproject_extra_key():
example: dict[str, object] = {
"tool": {
"check-sdist": {
"sdists-only": [],
}
}
}
validator = validate_pyproject.api.Validator()
with pytest.raises(validate_pyproject.error_reporting.ValidationError):
validator(example)


def test_validate_pyproject_invalid_value():
example = {
"tool": {
"check-sdist": {
"sdist-only": [1],
}
}
}
validator = validate_pyproject.api.Validator()
with pytest.raises(validate_pyproject.error_reporting.ValidationError):
validator(example)

0 comments on commit 8b04dc2

Please sign in to comment.