test_wiki_slice_identity.py

tests/test_wiki_slice_identity.py

A test's slice is drawn as windows split at gaps, and is keyed by file and name (P4; 2.0.0: W10, W11 of the hard-coded-assumptions review).

test_a_per_test_key_carries_the_file

None test_wiki_slice_identity.test_a_per_test_key_carries_the_file()

pytest node id → `file::name`; parameters and classes dropped; setup phase ignored.

tests/test_wiki_slice_identity.py:66

Checks

  • assert _context_test("tests/test_a.py::TestK::test_x[p::q]|run") == "tests/test_a.py::test_x"
  • assert _context_test("tests/test_b.py::test_x|run") == "tests/test_b.py::test_x"
  • assert _context_test("tests/test_b.py::test_x|setup") == ""
  • assert test_name("tests/test_b.py::test_x") == "test_x"
  • assert test_name("an LCOV TN name") == "an LCOV TN name"

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-041measuredtest_a_per_test_key_carries_the_file → test_name
Source · 9 lines
def test_a_per_test_key_carries_the_file() -> None:
    """@brief pytest node id → `file::name`; parameters and classes dropped; setup phase ignored."""
    assert _context_test("tests/test_a.py::TestK::test_x[p::q]|run") == "tests/test_a.py::test_x"
    assert _context_test("tests/test_b.py::test_x|run") == "tests/test_b.py::test_x"
    assert _context_test("tests/test_b.py::test_x|setup") == ""
    assert test_name("tests/test_b.py::test_x") == "test_x"
    assert test_name("an LCOV TN name") == "an LCOV TN name"

Activity · 5 steps
lines 68–68assert _context_test("tests/test_a.py::TestK::test_x[p::q]|run") == "tests/test_a.py::test_x"lines 69–69assert _context_test("tests/test_b.py::test_x|run") == "tests/test_b.py::test_x"lines 70–70assert _context_test("tests/test_b.py::test_x|setup") == ""lines 71–71assert test_name("tests/test_b.py::test_x") == "test_x"lines 72–72assert test_name("an LCOV TN name") == "an LCOV TN name"

test_a_slice_with_a_gap_is_two_windows_with_the_gap_counted

None test_wiki_slice_identity.test_a_slice_with_a_gap_is_two_windows_with_the_gap_counted()

Steps 2 and 40 of 50: two windows, the 33 steps between counted, not drawn.

tests/test_wiki_slice_identity.py:53

Show on the map →

Called by none

Calls _flow, slice_svg

Checks

  • assert html.count("<svg") == 2
  • assert "… 33 steps between" in html
  • assert "… 45 later steps" not in html

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-041measuredtest_a_slice_with_a_gap_is_two_windows_with_the_gap_counted → slice_svg
Source · 8 lines
def test_a_slice_with_a_gap_is_two_windows_with_the_gap_counted() -> None:
    """@brief Steps 2 and 40 of 50: two windows, the 33 steps between counted, not drawn."""
    html = slice_svg(_flow(50), Slice(exercised=(2, 40)), pad=2)
    assert html.count("<svg") == 2
    assert "… 33 steps between" in html
    assert "… 45 later steps" not in html

Activity · 4 steps
lines 55–55html = slice_svg(_flow(50), Slice(exercised=(2, 40)), pad=2)lines 56–56assert html.count("<svg") == 2lines 57–57assert "… 33 steps between" in htmllines 58–58assert "… 45 later steps" not in html

test_adjacent_exercised_steps_stay_one_window

None test_wiki_slice_identity.test_adjacent_exercised_steps_stay_one_window()

Steps 2 and 5 with pad 2: the windows overlap, so one is drawn.

tests/test_wiki_slice_identity.py:61

Show on the map →

Called by none

Calls _flow, slice_svg

Checks

  • assert slice_svg(_flow(50), Slice(exercised=(2, 5)), pad=2).count("<svg") == 1

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-041measuredtest_adjacent_exercised_steps_stay_one_window → slice_svg
Source · 5 lines
def test_adjacent_exercised_steps_stay_one_window() -> None:
    """@brief Steps 2 and 5 with pad 2: the windows overlap, so one is drawn."""
    assert slice_svg(_flow(50), Slice(exercised=(2, 5)), pad=2).count("<svg") == 1

Activity · 1 steps
lines 63–63assert slice_svg(_flow(50), Slice(exercised=(2, 5)), pad=2).count("<svg") == 1

test_two_namesakes_keep_their_own_slices_on_the_page

None test_wiki_slice_identity.test_two_namesakes_keep_their_own_slices_on_the_page()

One page, two definitions, each with its own flows listed under its file.

tests/test_wiki_slice_identity.py:75

Show on the map →

Called by none

Calls _exercises

Checks

  • assert html.index("tests/test_a.py") < html.index("Flow alpha") < html.index("tests/test_b.py")
  • assert html.index("tests/test_b.py") < html.index("Flow beta")

Result: passed

Verifies

requirementlinkedpath to the implementer
REQ-DDB-WIKI-041measuredtest_two_namesakes_keep_their_own_slices_on_the_page → _exercises
Source · 15 lines
def test_two_namesakes_keep_their_own_slices_on_the_page() -> None:
    """@brief One page, two definitions, each with its own flows listed under its file."""
    from clew.wiki.testpages import _exercises

    page = lambda name: SimpleNamespace(name=name, title=f"Flow {name}", steps=3, flow=None)  # noqa: E731
    ctx = {
        "slices": {
            "tests/test_a.py::test_x": [(page("alpha"), Slice())],
            "tests/test_b.py::test_x": [(page("beta"), Slice())],
        }
    }
    defs = [SimpleNamespace(file="tests/test_a.py"), SimpleNamespace(file="tests/test_b.py")]
    html = _exercises("test_x", ctx, defs)
    assert html.index("tests/test_a.py") < html.index("Flow alpha") < html.index("tests/test_b.py")
    assert html.index("tests/test_b.py") < html.index("Flow beta")

1 more lines, not shown

Activity · 7 steps
lines 77–77from clew.wiki.testpages import _exerciseslines 79–79page = lambda name: SimpleNamespace(name=name, title=f"Flow {name}", steps=3, flow=None)lines 80–85ctx = { "slices": { "tests/test_a.py::test_x": [(page("alpha"), Slice())], "tests/test_b.py::test_x": [(page("beta"), Slice())], } }lines 86–86defs = [SimpleNamespace(file="tests/test_a.py"), SimpleNamespace(file="tests/test_b.py")]lines 87–87html = _exercises("test_x", ctx, defs)lines 88–88assert html.index("tests/test_a.py") < html.index("Flow alpha") < html.index("tests/test_b.py")lines 89–89assert html.index("tests/test_b.py") < html.index("Flow beta")