test_guard_exemption_reason.py¶
tests/guard/test_guard_exemption_reason.py
An exemption can be required to say why (PG3b; 2.0.0, owner Q/A 2026-11-19).
test_a_bare_exemption_is_refused_when_reasons_are_required
None test_guard_exemption_reason.test_a_bare_exemption_is_refused_when_reasons_are_required(str tag)
No reason, switch on: one violation naming the tag.
tests/guard/test_guard_exemption_reason.py:38
Checks
assert f"@{tag}" in v.message and "reason" in v.message
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-001 | measured | test_a_bare_exemption_is_refused_when_reasons_are_required → check_exemption_reasons |
Source · 6 lines
def test_a_bare_exemption_is_refused_when_reasons_are_required(tag: str) -> None:
"""@brief No reason, switch on: one violation naming the tag."""
(v,) = check_exemption_reasons(_func(tag, ""), "a.c", _REQUIRED)
assert f"@{tag}" in v.message and "reason" in v.message
Activity · 2 steps
test_a_reasoned_exemption_passes
None test_guard_exemption_reason.test_a_reasoned_exemption_passes()
A one-line reason satisfies it.
tests/guard/test_guard_exemption_reason.py:44
Checks
assert (check_exemption_reasons(_func("utility", "parses the header for the loader"), "a.c", _REQUIRED ) == [] )
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-001 | measured | test_a_reasoned_exemption_passes → check_exemption_reasons |
Source · 10 lines
def test_a_reasoned_exemption_passes() -> None:
"""@brief A one-line reason satisfies it."""
assert (
check_exemption_reasons(
_func("utility", "parses the header for the loader"), "a.c", _REQUIRED
)
== []
)
Activity · 1 steps
test_an_unknown_setting_is_refused
None test_guard_exemption_reason.test_an_unknown_setting_is_refused()
`required` or `optional`; anything else named.
tests/guard/test_guard_exemption_reason.py:59
Checks
assert any("exemption_reason" in e for e in errors), errors
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-012 | measured | test_an_unknown_setting_is_refused → validate_config_schema |
Source · 4 lines
def test_an_unknown_setting_is_refused() -> None:
"""@brief `required` or `optional`; anything else named."""
errors = validate_config_schema({"validate": {"exemption_reason": "mandatory"}})
assert any("exemption_reason" in e for e in errors), errors1 more lines, not shown
Activity · 2 steps
test_reasons_are_optional_by_default
None test_guard_exemption_reason.test_reasons_are_optional_by_default()
Default: a bare exemption is fine.
tests/guard/test_guard_exemption_reason.py:54
Checks
assert check_exemption_reasons(_func("utility", ""), "a.c", CONFIG_DEFAULTS) == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-GUARD-001 | measured | test_reasons_are_optional_by_default → check_exemption_reasons |
Source · 5 lines
def test_reasons_are_optional_by_default() -> None:
"""@brief Default: a bare exemption is fine."""
assert check_exemption_reasons(_func("utility", ""), "a.c", CONFIG_DEFAULTS) == []