test_substrate_capability.py

tests/test_substrate_capability.py

What the substrate can parse is a measurement, never a version comparison.

test_a_language_the_substrate_does_not_have_is_absent

None test_substrate_capability.test_a_language_the_substrate_does_not_have_is_absent()

A negative, so the set is not merely non-empty.

tests/test_substrate_capability.py:51

Checks

  • assert not substrate.has_language("cobol")

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-012measuredtest_a_language_the_substrate_does_not_have_is_absent → has_language
Source · 5 lines
def test_a_language_the_substrate_does_not_have_is_absent() -> None:
    """@brief A negative, so the set is not merely non-empty. @version 1"""
    assert not substrate.has_language("cobol")

Activity · 1 steps
lines 53–53assert not substrate.has_language("cobol")

test_an_unimportable_substrate_degrades_rather_than_raising

None test_substrate_capability.test_an_unimportable_substrate_degrades_rather_than_raising(pytest.MonkeyPatch monkeypatch)

No substrate means no languages, not an exception.

tests/test_substrate_capability.py:78

Checks

  • assert substrate.compiled_languages() == frozenset()
  • assert not substrate.has_language("c")

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-012measuredtest_an_unimportable_substrate_degrades_rather_than_raising → compiled_languages
Source · 15 lines
def test_an_unimportable_substrate_degrades_rather_than_raising(
    monkeypatch: pytest.MonkeyPatch,
) -> None:
    """The substrate is a hard dependency, so this should not happen — but the gate is
    consulted on the gate's path too, and a front end that cannot run must say so rather
    than take the build down.

    @brief No substrate means no languages, not an exception. @version 1
    """
    monkeypatch.setitem(sys.modules, "lang_parsing_substrate", None)
    substrate.compiled_languages.cache_clear()
    assert substrate.compiled_languages() == frozenset()
    assert not substrate.has_language("c")

Activity · 4 steps
lines 87–87monkeypatch.setitem(sys.modules, "lang_parsing_substrate", None)lines 88–88substrate.compiled_languages.cache_clear()lines 89–89assert substrate.compiled_languages() == frozenset()lines 90–90assert not substrate.has_language("c")

test_missing_languages_is_empty_when_everything_asked_for_is_present

None test_substrate_capability.test_missing_languages_is_empty_when_everything_asked_for_is_present()

The empty answer is the one a front end acts on.

tests/test_substrate_capability.py:73

Checks

  • assert substrate.missing_languages(_ALWAYS) == ()

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-012measuredtest_missing_languages_is_empty_when_everything_asked_for_is_present → missing_languages
Source · 5 lines
def test_missing_languages_is_empty_when_everything_asked_for_is_present() -> None:
    """@brief The empty answer is the one a front end acts on. @version 1"""
    assert substrate.missing_languages(_ALWAYS) == ()

Activity · 1 steps
lines 75–75assert substrate.missing_languages(_ALWAYS) == ()

test_the_gate_is_capability_not_version

None test_substrate_capability.test_the_gate_is_capability_not_version(pytest.MonkeyPatch monkeypatch)

Version 0.12.0 with no bash means has_language('bash') is False.

tests/test_substrate_capability.py:56

Checks

  • assert substrate.has_language("c")
  • assert not substrate.has_language("bash")
  • assert substrate.missing_languages(("c", "bash", "cmake")) == ("bash", "cmake")

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-012measuredtest_the_gate_is_capability_not_version → has_language
Source · 17 lines
def test_the_gate_is_capability_not_version(monkeypatch: pytest.MonkeyPatch) -> None:
    """A stand-in carrying a version that publishes bash while reporting a language set
    without it is the state a wheel built with fewer cargo features leaves behind.

    @brief Version 0.12.0 with no bash means has_language('bash') is False. @version 2
    """
    fake = types.ModuleType("lang_parsing_substrate")
    fake.__version__ = "0.12.0"
    fake.languages = lambda: [types.SimpleNamespace(key=k) for k in _ALWAYS]
    monkeypatch.setitem(sys.modules, "lang_parsing_substrate", fake)
    substrate.compiled_languages.cache_clear()

    assert substrate.has_language("c")
    assert not substrate.has_language("bash")
    assert substrate.missing_languages(("c", "bash", "cmake")) == ("bash", "cmake")

Activity · 8 steps
lines 62–62fake = types.ModuleType("lang_parsing_substrate")lines 63–63fake.__version__ = "0.12.0"lines 64–64fake.languages = lambda: [types.SimpleNamespace(key=k) for k in _ALWAYS]lines 65–65monkeypatch.setitem(sys.modules, "lang_parsing_substrate", fake)lines 66–66substrate.compiled_languages.cache_clear()lines 68–68assert substrate.has_language("c")lines 69–69assert not substrate.has_language("bash")lines 70–70assert substrate.missing_languages(("c", "bash", "cmake")) == ("bash", "cmake")

test_the_languages_the_substrate_has_always_had_are_reported

None test_substrate_capability.test_the_languages_the_substrate_has_always_had_are_reported()

The gate reads the real module.

tests/test_substrate_capability.py:43

Checks

  • assert isinstance(keys, frozenset)
  • assert key in keys, f"{key} absent from a substrate that must have it: {sorted(keys)}"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-012measuredtest_the_languages_the_substrate_has_always_had_are_reported → compiled_languages
Source · 8 lines
def test_the_languages_the_substrate_has_always_had_are_reported() -> None:
    """@brief The gate reads the real module. @version 1"""
    keys = substrate.compiled_languages()
    assert isinstance(keys, frozenset)
    for key in _ALWAYS:
        assert key in keys, f"{key} absent from a substrate that must have it: {sorted(keys)}"

Activity · 4 steps
lines 45–45keys = substrate.compiled_languages()lines 46–46assert isinstance(keys, frozenset)lines 47–47◇ for key in _ALWAYSlines 48–48assert key in keys, f"{key} absent from a substrate that must have it: {sorted(keys)}"

test_the_required_substrate_has_the_configuration_languages

None test_substrate_capability.test_the_required_substrate_has_the_configuration_languages()

The installed wheel carries all five configuration grammars.

tests/test_substrate_capability.py:93

Checks

  • assert not missing, f"lang-parsing-substrate>=0.12.0 is required; absent: {missing}"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-PIPE-012measuredtest_the_required_substrate_has_the_configuration_languages → missing_languages
Source · 9 lines
def test_the_required_substrate_has_the_configuration_languages() -> None:
    """Not a property of clew — a check that THIS venv's wheel meets the dependency floor,
    so the front-end tests that skip on a missing grammar are exercising real grammars
    rather than skipping in silence.

    @brief The installed wheel carries all five configuration grammars. @version 2
    """
    missing = substrate.missing_languages(_CONFIGURATION)
    assert not missing, f"lang-parsing-substrate>=0.12.0 is required; absent: {missing}"

1 more lines, not shown

Activity · 2 steps
lines 100–100missing = substrate.missing_languages(_CONFIGURATION)lines 101–101assert not missing, f"lang-parsing-substrate>=0.12.0 is required; absent: {missing}"