From fa4fe00e3ec5732ee64e73e8e3501d7a5827f4e2 Mon Sep 17 00:00:00 2001 From: Joel Ostblom Date: Thu, 27 Nov 2025 11:16:02 +0100 Subject: [PATCH 1/8] feat: Add optional debug output --- src/check_datapackage/check.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/check_datapackage/check.py b/src/check_datapackage/check.py index 2eeb328e..8e683fdf 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 @@ -6,6 +7,7 @@ from typing import Any, Callable, Iterator, Optional from jsonschema import Draft7Validator, FormatChecker, ValidationError +from rich import print as rprint from check_datapackage.config import Config from check_datapackage.constants import ( @@ -130,6 +132,11 @@ class for more details, especially about the default values. issues = exclude(issues, config.exclusions, properties) issues = sorted(set(issues)) + if os.getenv("CDP_DEBUG"): + rprint("", properties) + rprint(*issues) + rprint(explain(issues)) + if error and issues: raise DataPackageError(issues) From 1352ccc39980470dbd7da22983b4ebcf2b2b11e1 Mon Sep 17 00:00:00 2001 From: Joel Ostblom Date: Thu, 27 Nov 2025 11:32:12 +0100 Subject: [PATCH 2/8] feat: Add newline separation in tets with debug output --- tests/conftest.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 tests/conftest.py diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 00000000..fa9341a6 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,14 @@ +import os + + +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 From 40542c1522a7ac796f5e3b1438cdf1fc4b13df5b Mon Sep 17 00:00:00 2001 From: Joel Ostblom Date: Sat, 20 Dec 2025 08:15:33 +0100 Subject: [PATCH 3/8] fix: Add explaining commet Co-authored-by: Luke W. Johnston --- src/check_datapackage/check.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/check_datapackage/check.py b/src/check_datapackage/check.py index 082463db..36c63a7d 100644 --- a/src/check_datapackage/check.py +++ b/src/check_datapackage/check.py @@ -182,6 +182,7 @@ 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) rprint(*issues) From 8e5a6f1e3d1f14527be4dcd82f9c3cc62782c970 Mon Sep 17 00:00:00 2001 From: Joel Ostblom Date: Sat, 20 Dec 2025 08:18:06 +0100 Subject: [PATCH 4/8] feat: Print each explanation right after each issue Co-authored-by: Luke W. Johnston --- src/check_datapackage/check.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/check_datapackage/check.py b/src/check_datapackage/check.py index 36c63a7d..e49ce9e6 100644 --- a/src/check_datapackage/check.py +++ b/src/check_datapackage/check.py @@ -185,8 +185,9 @@ class for more details, especially about the default values. # Use by doing `CDP_DEBUG=true uv run ...` if os.getenv("CDP_DEBUG"): rprint("", properties) - rprint(*issues) - rprint(explain(issues)) + for issue in issues: + rprint(issue) + rprint(explain([issue])) if error and issues: raise DataPackageError(issues) From d19f5e6cf371509e87ad5016c1521726e88e1efc Mon Sep 17 00:00:00 2001 From: Joel Ostblom Date: Sat, 20 Dec 2025 08:29:08 +0100 Subject: [PATCH 5/8] fix: :bug: Add conftest function to allowlist to pass cov tests --- tools/vulture-allowlist.py | 1 + 1 file changed, 1 insertion(+) 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) From 3d34062e22032adc5761b053a394a8e386017bf9 Mon Sep 17 00:00:00 2001 From: Joel Ostblom Date: Sat, 20 Dec 2025 08:33:24 +0100 Subject: [PATCH 6/8] docs: :memo: Add notes about run command Co-authored-by: Luke W. Johnston --- tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index fa9341a6..e0ca5dae 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,6 +1,6 @@ import os - +# Can get debug output by using `CDP_DEBUG=true uv run pytest -sv tests/test_check.py` def pytest_report_teststatus(report, config): if os.getenv("CDP_DEBUG"): if report.when == "call": From 40ed6f71c83435d6ae74615be9dbdfcc9033ad8b Mon Sep 17 00:00:00 2001 From: Joel Ostblom Date: Sat, 20 Dec 2025 08:37:24 +0100 Subject: [PATCH 7/8] fix: :bug: Fix ruff spacing --- tests/conftest.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/conftest.py b/tests/conftest.py index e0ca5dae..35b5436f 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,5 +1,6 @@ import os + # Can get debug output by using `CDP_DEBUG=true uv run pytest -sv tests/test_check.py` def pytest_report_teststatus(report, config): if os.getenv("CDP_DEBUG"): From d840ac48651e42d17be0f0da85061a5b6a91b256 Mon Sep 17 00:00:00 2001 From: Joel Ostblom Date: Sat, 20 Dec 2025 08:50:31 +0100 Subject: [PATCH 8/8] feat: :sparkles: Add build command --- justfile | 6 ++++++ tests/conftest.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) 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/tests/conftest.py b/tests/conftest.py index 35b5436f..e229a4ae 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,7 +1,7 @@ import os -# Can get debug output by using `CDP_DEBUG=true uv run pytest -sv tests/test_check.py` +# 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":