Validating PyProject Schema Configuration in Black
This test suite validates the schema configuration for Black’s pyproject.toml integration, focusing on entry point registration and schema validation for the Black code formatter.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
psf/black
tests/test_schema.py
import importlib.metadata
import sys
def test_schema_entrypoint() -> None:
if sys.version_info < (3, 10):
eps = importlib.metadata.entry_points()["validate_pyproject.tool_schema"]
(black_ep,) = [ep for ep in eps if ep.name == "black"]
else:
(black_ep,) = importlib.metadata.entry_points(
group="validate_pyproject.tool_schema", name="black"
)
black_fn = black_ep.load()
schema = black_fn()
assert schema == black_fn("black")
assert schema["properties"]["line-length"]["type"] == "integer"