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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-043 | catalog | |
| REQ-DDB-WIKI-044 | measured |
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
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
Checks
assert [p.line for p in pins] == [12, 13, 14, 15], relassert pins[1].bound_line == 11 and pins[0].bound_line is None, rel
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-043 | measured | test_a_pin_carries_its_lines_for_pairing_with_a_run → pin_checks |
| REQ-DDB-WIKI-044 | catalog |
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
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
Checks
assert '<span class="traced">returned <code>2</code> in the recorded run</span>' in htmlassert "traced" not in _pinned(Pin("assert x", "not attributed", line=13), None)
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-043 | measured | test_a_pinned_check_shows_its_traced_value → _pinned |
| REQ-DDB-WIKI-044 | catalog |
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
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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-043 | catalog | |
| REQ-DDB-WIKI-044 | measured |
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
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
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
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-035 | measured | test_a_traced_run_gives_each_pinned_check_the_value_it_saw → traced_values → spans_of |
| REQ-DDB-WIKI-043 | measured | test_a_traced_run_gives_each_pinned_check_the_value_it_saw → pin_checks |
| REQ-DDB-WIKI-044 | catalog |
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
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
Checks
assert pin_checks(["assert x"], "tests/t.zig", {"x"}) == []
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-043 | measured | test_an_unknown_language_pins_nothing → pin_checks |
| REQ-DDB-WIKI-044 | catalog |
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
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
Checks
assert _kinds(pins) == [
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-043 | measured | test_cpp_checks_are_pinned_through_the_assertion_macros → pin_checks |
| REQ-DDB-WIKI-044 | catalog |
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
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
Checks
assert _kinds(pins) == [assert pins[1].variable == "r"assert pins[0].statement == "assert save(2) == 2"
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-043 | measured | test_python_checks_are_pinned_direct_via_variable_or_not → pin_checks |
| REQ-DDB-WIKI-044 | catalog |
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"