test_wiki_slices.py¶
tests/test_wiki_slices.py
A test is a slice of a master flow (round 5, R5-4a).
test_a_slice_is_drawn_as_a_window_of_the_master_flow
None test_wiki_slices.test_a_slice_is_drawn_as_a_window_of_the_master_flow()
Window of the master flow with the slice lit.
Checks
assert {v: k for k, v in groups.items()} == {"1": "ex entry", "2": "ex"}assert ">2<" in html and ">3<" in html # master numbering keptassert "test enters" in htmlassert "1 earlier step" in html and "2 later steps" in htmlassert 'data-step="0"' in wide and 'class="st dim" data-step="3"' in wide
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-041 | measured | test_a_slice_is_drawn_as_a_window_of_the_master_flow → lines_per_test |
Source · 22 lines
def test_a_slice_is_drawn_as_a_window_of_the_master_flow() -> None:
"""THE PORTION OF THE DIAGRAM: the window runs from `pad` steps before the first exercised step
to `pad` after the last, numbered as in the master flow; exercised steps are lit (`ex`), the
rest dimmed (`dim`); the test's entry is marked; the steps outside the window are counted.
@brief Window of the master flow with the slice lit.
"""
import re
from clew.wiki.slices import slice_svg
cut = slice_of(_FLOW, lines_per_test(_CONTEXTS)["test_load"])
html = slice_svg(_FLOW, cut, pad=0)
groups = dict(re.findall(r'<g class="st ([a-z ]+)" data-step="(\d+)"', html))
assert {v: k for k, v in groups.items()} == {"1": "ex entry", "2": "ex"}
assert ">2<" in html and ">3<" in html # master numbering kept
assert "test enters" in html
assert "1 earlier step" in html and "2 later steps" in html
wide = slice_svg(_FLOW, cut, pad=1)
assert 'data-step="0"' in wide and 'class="st dim" data-step="3"' in wide
Activity · 11 steps
test_a_step_is_exercised_when_its_call_site_ran_in_the_test
None test_wiki_slices.test_a_step_is_exercised_when_its_call_site_ran_in_the_test()
Exercised = call-site line ran in this test.
Checks
assert cut.exercised == (0, 1, 3, 4)assert cut.entered == ("main",)
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-041 | measured | test_a_step_is_exercised_when_its_call_site_ran_in_the_test → lines_per_test |
Source · 11 lines
def test_a_step_is_exercised_when_its_call_site_ran_in_the_test() -> None:
"""test_main ran lines 10, 11, 20, 30 but not 21: check() was never called from load in that
test, so step 2 (load → check) is not part of what test_main validates.
@brief Exercised = call-site line ran in this test.
"""
cut = slice_of(_FLOW, lines_per_test(_CONTEXTS)["test_main"])
assert cut.exercised == (0, 1, 3, 4)
assert cut.entered == ("main",)
Activity · 3 steps
test_a_test_that_calls_into_the_middle_enters_there
None test_wiki_slices.test_a_test_that_calls_into_the_middle_enters_there()
Mid-flow entry is where the test called in.
Checks
assert cut.exercised == (1, 2)assert cut.entered == ("load",)
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-041 | measured | test_a_test_that_calls_into_the_middle_enters_there → lines_per_test |
Source · 11 lines
def test_a_test_that_calls_into_the_middle_enters_there() -> None:
"""test_load called load() itself: its calls ran (20, 21) but the step main → load did not,
so the test enters the flow at load, and main's own steps are outside its slice.
@brief Mid-flow entry is where the test called in.
"""
cut = slice_of(_FLOW, lines_per_test(_CONTEXTS)["test_load"])
assert cut.exercised == (1, 2)
assert cut.entered == ("load",)
Activity · 3 steps
test_a_test_that_ran_none_of_the_flow_has_an_empty_slice
None test_wiki_slices.test_a_test_that_ran_none_of_the_flow_has_an_empty_slice()
Nothing ran → nothing exercised, nowhere entered (and never an error).
Checks
assert cut.exercised == () and cut.entered == ()
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-041 | measured | test_a_test_that_ran_none_of_the_flow_has_an_empty_slice → slice_of |
Source · 6 lines
def test_a_test_that_ran_none_of_the_flow_has_an_empty_slice() -> None:
"""@brief Nothing ran → nothing exercised, nowhere entered (and never an error)."""
cut = slice_of(_FLOW, {"src/other.py": {1}})
assert cut.exercised == () and cut.entered == ()
Activity · 2 steps
test_every_test_s_slice_of_a_flow_comes_from_one_pass_over_its_steps
None test_wiki_slices.test_every_test_s_slice_of_a_flow_comes_from_one_pass_over_its_steps()
All slices of a flow, equal to the per-test ones.
Checks
assert set(every) == {"test_main", "test_load"}assert all(every[t] == slice_of(_FLOW, per_test[t]) for t in every)
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-041 | measured | test_every_test_s_slice_of_a_flow_comes_from_one_pass_over_its_steps → lines_per_test |
| REQ-DDB-WIKI-054 | inferred | test_every_test_s_slice_of_a_flow_comes_from_one_pass_over_its_steps → all |
Source · 13 lines
def test_every_test_s_slice_of_a_flow_comes_from_one_pass_over_its_steps() -> None:
"""A FLOW PAGE NEEDS ALL ITS TESTS' SLICES at once (clew: ~2,900 tests); `slices_of` reads them
from the steps' call sites in one pass, and agrees with `slice_of` test by test. A test that
touched none of the flow is absent, not an empty slice.
@brief All slices of a flow, equal to the per-test ones.
"""
from clew.wiki.slices import slices_of
every = slices_of(_FLOW, _CONTEXTS)
per_test = lines_per_test(_CONTEXTS)
assert set(every) == {"test_main", "test_load"}
assert all(every[t] == slice_of(_FLOW, per_test[t]) for t in every)1 more lines, not shown
Activity · 5 steps
test_lines_are_grouped_per_test
None test_wiki_slices.test_lines_are_grouped_per_test()
{file: {line: tests}} turns into {test: {file: lines}}.
Checks
assert lines["test_load"] == {"src/app.py": {20, 21}}assert lines["test_main"]["src/app.py"] == {10, 11, 20, 30}
Result: passed
Verifies
| requirement | linked | path to the implementer |
|---|---|---|
| REQ-DDB-WIKI-041 | measured | test_lines_are_grouped_per_test → lines_per_test |
Source · 7 lines
def test_lines_are_grouped_per_test() -> None:
"""@brief {file: {line: tests}} turns into {test: {file: lines}}."""
lines = lines_per_test(_CONTEXTS)
assert lines["test_load"] == {"src/app.py": {20, 21}}
assert lines["test_main"]["src/app.py"] == {10, 11, 20, 30}