testcard.py¶
clew/wiki/testcard.py
The test card: WHY a test exists and WHAT it checks, at the top of its page (owner review 3).
test_card
str clew.wiki.testcard.test_card(list[str] lines, Any d, set[str] product, Any facts, str brief="")
The card: WHY, then Given / When / Then, for one test definition.
Called by _card, _card
Tested by
Calls _docstring_why, _phases, _phases_html, _why_html
Source · 19 lines
def test_card(lines: list[str], d: Any, product: set[str], facts: Any, brief: str = "") -> str:
"""ABSENT, NOT INVENTED: a part the test does not have is not drawn.
@brief Test card.
@return HTML.
"""
src = textwrap.dedent("\n".join(lines))
fn = _parse(src, d.name) if d.file.endswith(".py") else None
why = (_docstring_why(fn) if fn else "") or brief
reqs = [r for r, kind in getattr(facts, "verifies", ()) if kind in DECLARED_LINKS]
status = getattr(facts, "status", "absent") or "absent"
parts = [_why_html(why, reqs)]
if fn is not None:
parts.append(_phases_html(_phases(fn, product, src), status))
return (
'<section class="test-card"><h2>What this test is for</h2>' + "".join(parts) + "</section>"
)