diff --git a/justfile b/justfile index 7fd37a82..c8cb27bd 100644 --- a/justfile +++ b/justfile @@ -42,6 +42,12 @@ test-python: -i coverage.xml \ -o htmlcov/coverage.svg +# View debug information for all tests +# Used to e.g. view output of explain() rather than seeing which tests failed +test-python-debug: + CDP_DEBUG=true uv run pytest -sv + + # Check Python code for any errors that need manual attention check-python: # Check formatting diff --git a/src/check_datapackage/check.py b/src/check_datapackage/check.py index fe56bb92..e49ce9e6 100644 --- a/src/check_datapackage/check.py +++ b/src/check_datapackage/check.py @@ -1,3 +1,4 @@ +import os import re import sys from dataclasses import dataclass, field @@ -181,6 +182,13 @@ class for more details, especially about the default values. issues = exclude(issues, config.exclusions) issues = sorted(set(issues)) + # Use by doing `CDP_DEBUG=true uv run ...` + if os.getenv("CDP_DEBUG"): + rprint("", properties) + for issue in issues: + rprint(issue) + rprint(explain([issue])) + if error and issues: raise DataPackageError(issues) diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 00000000..e229a4ae --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,15 @@ +import os + + +# Can get debug output by using `CDP_DEBUG=true uv run pytest -sv` +def pytest_report_teststatus(report, config): + if os.getenv("CDP_DEBUG"): + if report.when == "call": + # Add newlines to separate test results + category = report.outcome + shortletter = "\n\n" # dot / F / X / etc. + verbose = "\n\n" # ("PASSED", "FAILED", ...) + + return category, shortletter, verbose + + return None diff --git a/tools/vulture-allowlist.py b/tools/vulture-allowlist.py index 0c3fedd3..973ecae2 100644 --- a/tools/vulture-allowlist.py +++ b/tools/vulture-allowlist.py @@ -4,3 +4,4 @@ _check_not_required # unused method (src/check_datapackage/extensions.py:59) _check_field_name_in_jsonpath # unused method (src/check_datapackage/extensions.py:117) cls # unused variable (src/check_datapackage/extensions.py:61) +pytest_report_teststatus # unused function (tests/conftest.py:4)