test_wiki_checkpins.py

tests/test_wiki_checkpins.py

A test's checks, pinned by syntax tree to the function each one observes (round 5, P5.5).

test_a_flow_that_only_starts_at_the_function_is_the_fallback

None test_wiki_checkpins.test_a_flow_that_only_starts_at_the_function_is_the_fallback()

A caller chain beats "is the entry"; the entry form is shown only alone.

tests/test_wiki_checkpins.py:155

Show on the map →

Called by none

Calls none

Checks

  • assert "<code>main</code> → <code>save</code>" in _context({"save"}, [own, main])
  • assert "<code>save</code> is the entry of the flow" in _context({"save"}, [own])

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-043catalog
REQ-DDB-WIKI-044measured
Source · 9 lines
def test_a_flow_that_only_starts_at_the_function_is_the_fallback() -> None:
    """@brief A caller chain beats "is the entry"; the entry form is shown only alone."""
    from clew.wiki.flowpage import FlowPage
    from clew.wiki.testpages import _context

    own = FlowPage("flow-save", "save", frozenset(), calls=(("save", "write"),), role="product")
    main = FlowPage("flow-main", "main", frozenset(), calls=(("main", "save"),), role="product")
    assert "<code>main</code> → <code>save</code>" in _context({"save"}, [own, main])
    assert "<code>save</code> is the entry of the flow" in _context({"save"}, [own])

1 more lines, not shown

Activity · 6 steps
lines 157–157from clew.wiki.flowpage import FlowPagelines 158–158from clew.wiki.testpages import _contextlines 160–160own = FlowPage("flow-save", "save", frozenset(), calls=(("save", "write"),), role="product")lines 161–161main = FlowPage("flow-main", "main", frozenset(), calls=(("main", "save"),), role="product")lines 162–162assert "<code>main</code> → <code>save</code>" in _context({"save"}, [own, main])lines 163–163assert "<code>save</code> is the entry of the flow" in _context({"save"}, [own])

test_a_pin_carries_its_lines_for_pairing_with_a_run

None test_wiki_checkpins.test_a_pin_carries_its_lines_for_pairing_with_a_run()

Pins carry absolute lines.

tests/test_wiki_checkpins.py:75

Show on the map →

Called by none

Calls pin_checks

Checks

  • assert [p.line for p in pins] == [12, 13, 14, 15], rel
  • assert pins[1].bound_line == 11 and pins[0].bound_line is None, rel

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-043measuredtest_a_pin_carries_its_lines_for_pairing_with_a_run → pin_checks
REQ-DDB-WIKI-044catalog
Source · 13 lines
def test_a_pin_carries_its_lines_for_pairing_with_a_run() -> None:
    """2.0.0 (P5.5, traced values): the assertion's ABSOLUTE line, and for a via-variable check
    the line that bound the variable — the call sites a recorded run's spans are matched against.
    The body starts on line 10 of its file.

    @brief Pins carry absolute lines.
    """
    for rel, src in (("tests/test_store.py", _PY), ("tests/test_store.cpp", _CPP)):
        pins = pin_checks(src.splitlines(), rel, {"save", "clean"}, first_line=10)
        assert [p.line for p in pins] == [12, 13, 14, 15], rel
        assert pins[1].bound_line == 11 and pins[0].bound_line is None, rel

Activity · 4 steps
lines 82–82◇ for rel, src in (("tests/test_store.py", _PY), ("tests/test_store.cpp", _CPP))lines 83–83pins = pin_checks(src.splitlines(), rel, {"save", "clean"}, first_line=10)lines 84–84assert [p.line for p in pins] == [12, 13, 14, 15], rellines 85–85assert pins[1].bound_line == 11 and pins[0].bound_line is None, rel

test_a_pinned_check_shows_its_traced_value

None test_wiki_checkpins.test_a_pinned_check_shows_its_traced_value()

On the page: "observes `save` — returned `2` in the recorded run".

tests/test_wiki_checkpins.py:124

Show on the map →

Called by none

Calls _pinned

Checks

  • assert '<span class="traced">returned <code>2</code> in the recorded run</span>' in html
  • assert "traced" not in _pinned(Pin("assert x", "not attributed", line=13), None)

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-043measuredtest_a_pinned_check_shows_its_traced_value → _pinned
REQ-DDB-WIKI-044catalog
Source · 10 lines
def test_a_pinned_check_shows_its_traced_value() -> None:
    """@brief On the page: "observes `save` — returned `2` in the recorded run"."""
    from clew.wiki.checkpins import Pin
    from clew.wiki.testpages import _pinned

    html = _pinned(Pin("assert save(2) == 2", "direct", "save", line=12), "2")
    assert '<span class="traced">returned <code>2</code> in the recorded run</span>' in html
    assert "traced" not in _pinned(Pin("assert x", "not attributed", line=13), None)

Activity · 5 steps
lines 126–126from clew.wiki.checkpins import Pinlines 127–127from clew.wiki.testpages import _pinnedlines 129–129html = _pinned(Pin("assert save(2) == 2", "direct", "save", line=12), "2")lines 130–130assert '<span class="traced">returned <code>2</code> in the recorded run</span>' in htmllines 131–131assert "traced" not in _pinned(Pin("assert x", "not attributed", line=13), None)

test_a_test_no_product_flow_reaches_says_so

None test_wiki_checkpins.test_a_test_no_product_flow_reaches_says_so()

Context paths: the negative.

tests/test_wiki_checkpins.py:134

Show on the map →

Called by none

Calls none

Checks

  • assert "No product flow reaches" in _context({"helper"}, [tool, product])
  • assert ("<code>main</code> → <code>run</code> → <code>save</code>" in html and 'href="flow-main.html"' in html )

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-043catalog
REQ-DDB-WIKI-044measured
Source · 21 lines
def test_a_test_no_product_flow_reaches_says_so() -> None:
    """ABSENCE IS STATED (P5.5): a test whose calls no product flow reaches gets the sentence, not
    an empty space; a tooling flow does not count as the product.

    @brief Context paths: the negative.
    """
    from clew.wiki.flowpage import FlowPage
    from clew.wiki.testpages import _context

    tool = FlowPage("flow-gen", "gen", frozenset(), calls=(("gen", "helper"),), role="tooling")
    product = FlowPage(
        "flow-main", "main", frozenset(), calls=(("main", "run"), ("run", "save")), role="product"
    )
    assert "No product flow reaches" in _context({"helper"}, [tool, product])
    html = _context({"save"}, [tool, product])
    assert (
        "<code>main</code> → <code>run</code> → <code>save</code>" in html
        and 'href="flow-main.html"' in html
    )

Activity · 7 steps
lines 140–140from clew.wiki.flowpage import FlowPagelines 141–141from clew.wiki.testpages import _contextlines 143–143tool = FlowPage("flow-gen", "gen", frozenset(), calls=(("gen", "helper"),), role="tooling")lines 144–146product = FlowPage( "flow-main", "main", frozenset(), calls=(("main", "run"), ("run", "save")), role="product" )lines 147–147assert "No product flow reaches" in _context({"helper"}, [tool, product])lines 148–148html = _context({"save"}, [tool, product])lines 149–152assert ( "<code>main</code> → <code>run</code> → <code>save</code>" in html and 'href="flow-main.html"' in html )

test_a_traced_run_gives_each_pinned_check_the_value_it_saw

None test_wiki_checkpins.test_a_traced_run_gives_each_pinned_check_the_value_it_saw()

Traced values pair by call site.

tests/test_wiki_checkpins.py:100

Show on the map →

Called by none

Calls _otlp, _span, pin_checks, traced_values

Checks

  • assert traced_values(pins, otlp, "test_save") == {0: "2", 1: "1", 3: "1"}
  • assert traced_values(pins, old_run, "test_save") == {}, "no call line, no guessed pairing"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-035measuredtest_a_traced_run_gives_each_pinned_check_the_value_it_saw → traced_values → spans_of
REQ-DDB-WIKI-043measuredtest_a_traced_run_gives_each_pinned_check_the_value_it_saw → pin_checks
REQ-DDB-WIKI-044catalog
Source · 24 lines
def test_a_traced_run_gives_each_pinned_check_the_value_it_saw() -> None:
    """2.0.0 (P5.5, traced values): the span of the pinned function CALLED FROM THE TEST at the
    pin's call site — the assertion's own line when direct, the binding line when via a variable —
    gives the value the check observed. `save` is called twice; each check gets its own call's
    value. A check with no target, or a run without call lines, gets none.

    @brief Traced values pair by call site.
    """
    from clew.wiki.checkpins import traced_values

    pins = pin_checks(_PY.splitlines(), "tests/test_store.py", {"save", "clean"}, first_line=10)
    otlp = _otlp(
        [
            _span("t", "", "test_save"),
            _span("a", "t", "save", "11", "1"),
            _span("b", "t", "save", "12", "2"),
            _span("c", "t", "clean", "15", "1"),
        ]
    )
    assert traced_values(pins, otlp, "test_save") == {0: "2", 1: "1", 3: "1"}
    old_run = _otlp([_span("t", "", "test_save"), _span("a", "t", "save", "", "1")])
    assert traced_values(pins, old_run, "test_save") == {}, "no call line, no guessed pairing"

Activity · 6 steps
lines 108–108from clew.wiki.checkpins import traced_valueslines 110–110pins = pin_checks(_PY.splitlines(), "tests/test_store.py", {"save", "clean"}, first_line=10)lines 111–118otlp = _otlp( [ _span("t", "", "test_save"), _span("a", "t", "save", "11", "1"), _span("b", "t", "save", "12", "2"), _span("c", "t", "clean", "15", "1"), ] )lines 119–119assert traced_values(pins, otlp, "test_save") == {0: "2", 1: "1", 3: "1"}lines 120–120old_run = _otlp([_span("t", "", "test_save"), _span("a", "t", "save", "", "1")])lines 121–121assert traced_values(pins, old_run, "test_save") == {}, "no call line, no guessed pairing"

test_an_unknown_language_pins_nothing

None test_wiki_checkpins.test_an_unknown_language_pins_nothing()

No parser for the file: [] — the page then lists the checks unpinned, as before.

tests/test_wiki_checkpins.py:70

Show on the map →

Called by none

Calls pin_checks

Checks

  • assert pin_checks(["assert x"], "tests/t.zig", {"x"}) == []

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-043measuredtest_an_unknown_language_pins_nothing → pin_checks
REQ-DDB-WIKI-044catalog
Source · 5 lines
def test_an_unknown_language_pins_nothing() -> None:
    """@brief No parser for the file: [] — the page then lists the checks unpinned, as before."""
    assert pin_checks(["assert x"], "tests/t.zig", {"x"}) == []

Activity · 1 steps
lines 72–72assert pin_checks(["assert x"], "tests/t.zig", {"x"}) == []

test_cpp_checks_are_pinned_through_the_assertion_macros

None test_wiki_checkpins.test_cpp_checks_are_pinned_through_the_assertion_macros()

tree-sitter: REQUIRE / CHECK / EXPECT_EQ, the same three kinds.

tests/test_wiki_checkpins.py:59

Show on the map →

Called by none

Calls _kinds, pin_checks

Checks

  • assert _kinds(pins) == [

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-043measuredtest_cpp_checks_are_pinned_through_the_assertion_macros → pin_checks
REQ-DDB-WIKI-044catalog
Source · 11 lines
def test_cpp_checks_are_pinned_through_the_assertion_macros() -> None:
    """@brief tree-sitter: REQUIRE / CHECK / EXPECT_EQ, the same three kinds."""
    pins = pin_checks(_CPP.splitlines(), "tests/test_store.cpp", {"save", "clean"})
    assert _kinds(pins) == [
        ("direct", "save"),
        ("via variable", "save"),
        ("not attributed", None),
        ("direct", "clean"),
    ]

Activity · 2 steps
lines 61–61pins = pin_checks(_CPP.splitlines(), "tests/test_store.cpp", {"save", "clean"})lines 62–67assert _kinds(pins) == [ ("direct", "save"), ("via variable", "save"), ("not attributed", None), ("direct", "clean"), ]

test_python_checks_are_pinned_direct_via_variable_or_not

None test_wiki_checkpins.test_python_checks_are_pinned_direct_via_variable_or_not()

`ast`: direct, via `r`, not attributed, direct (the innermost known call).

tests/test_wiki_checkpins.py:46

Show on the map →

Called by none

Calls _kinds, pin_checks

Checks

  • assert _kinds(pins) == [
  • assert pins[1].variable == "r"
  • assert pins[0].statement == "assert save(2) == 2"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-043measuredtest_python_checks_are_pinned_direct_via_variable_or_not → pin_checks
REQ-DDB-WIKI-044catalog
Source · 13 lines
def test_python_checks_are_pinned_direct_via_variable_or_not() -> None:
    """@brief `ast`: direct, via `r`, not attributed, direct (the innermost known call)."""
    pins = pin_checks(_PY.splitlines(), "tests/test_store.py", {"save", "clean"})
    assert _kinds(pins) == [
        ("direct", "save"),
        ("via variable", "save"),
        ("not attributed", None),
        ("direct", "clean"),
    ]
    assert pins[1].variable == "r"
    assert pins[0].statement == "assert save(2) == 2"

Activity · 4 steps
lines 48–48pins = pin_checks(_PY.splitlines(), "tests/test_store.py", {"save", "clean"})lines 49–54assert _kinds(pins) == [ ("direct", "save"), ("via variable", "save"), ("not attributed", None), ("direct", "clean"), ]lines 55–55assert pins[1].variable == "r"lines 56–56assert pins[0].statement == "assert save(2) == 2"