Collector
What gathers a session's scenarios, fixture recordings and parameter info.
pytest-given report --report-url re-renders a saved report for another URL
/dev/--report-url set to /1.0//1.0/ URLcitations exit code says whether a citation finding remains, so CI can gate on it
pytest-given citations {command} runs on the document| citation | document | report_state | command | exit_code | rewritten |
|---|---|---|---|---|---|
| current | readable | check | 0 | False | |
| stale | readable | check | 1 | False | |
| stale | readable | update | 0 | True | |
| of a gone scenario | readable | update | 1 | True | |
| stale | unreadable | update | 2 | False | |
citations refuses documents that never link the report, rather than passing them
pytest-given citations check runs on the document--report, citations reads the JSON report a bare --given-json writes
given-report/report-data.jsonpytest-given citations update runs on it without --reportcitations check --list prints every report link, its findings under it
pytest-given citations check --list runs on the document--covering leaves report links out of the list but still counts their findings
test_refund, not test_paypytest-given citations check --covering names test_paytest_pay is listed@scenario stays out of the report
| first_case | id_column |
|---|---|
| pytest.param(20, False, id="touching-edges") | shown |
| (20, False) | omitted |
| case ID | value | error |
|---|---|---|
| misspelled-preset | bogus | Unknown --given-source-link preset |
| unknown-variable | {bogus} | Unknown source-link template variable |
| late | suite |
|---|---|
| step | |
| attachment | |
@given, never @when or @then
| decorator | suite |
|---|---|
| when | |
| then | |
a, and a given annotation with pins={annotation_pins} over a step fixture pinning a[1]a| case ID | annotation_pins | suite | root_sentences |
|---|---|---|---|
| none-keeps | None | [1] | |
| empty-clears | [] | [] | |
| list-replaces | [a[2]] | [2] | |
Template given annotation on an unparametrized scenario fails that scenario
Template given annotation on a plain fixture parameterTemplate given annotation may only hold a bare parametrize column
x, with a plain fixture room whose Template given annotation holds {placeholder}| case ID | placeholder | suite | error |
|---|---|---|---|
| plain-fixture | {room} | '{room}' in the given annotation on parameter 'room' does not match any parametrize column (have: ['x']). A given annotation reads only parametrize columns, not fixture values. To show a fixture value, narrate it in a t-string in the test body. | |
| attribute | {room.number} | only supports bare identifiers as placeholders; got 'room.number' | |
--given-md prints the narration to stdout
| mode | reason |
|---|---|
| --collect-only | a --collect-only run runs no tests |
| --setup-only | a --setup-only run stops before the tests |
| --setup-plan | a --setup-plan run plans setup but runs no tests |
given_md_lines = false
given_md_lines = false--given-md-source ends each scenario of the Markdown report with its test function, under its line numbers
--given-html alone writes no JSON report
--given-title names the report instead of the rootdir
--given-theme sets the theme the HTML report opens in
| case ID | workers | option | exit_code | ran |
|---|---|---|---|---|
| report | 2 | --given-json=report.json | 4 | False |
| lint | 2 | --given-lint | 4 | False |
| neither | 2 | --no-given-lint | 0 | True |
| serial-report | 0 | --given-json=report.json | 0 | True |
pytest_given marker
| suite | test file | entry | outcome |
|---|---|---|---|
| a flawed step | '' | reported | |
| a flawed step | '*::test_empty_given' | suppressed | |
| a flawed step | 'empty-step: *::test_empty_given' | suppressed | |
| a clean step | '*::test_nothing' | stale | |
skills install removes what no bundled file accounts for, the directories it empties included
work_object kind cell maps to the work object kind
| problem | Glossary file | message |
|---|---|---|
| no table | bad.md: found no Markdown pipe table | |
| a header but no data rows | bad.md: the glossary file's Markdown table has no data rows | |
| no Term column | bad.md: column 'Term' | |
| identical | Glossary file | outcome |
|---|---|---|
| True | one term | |
| False | refused | |
| text | slug |
|---|---|
| 'Guest' | 'guest' |
| 'Order received' | 'order-received' |
| ' Work Object ' | 'work-object' |
| 'do_the_thing' | 'do-the-thing' |
| 'Buy / sell' | 'buy-sell' |
| 'Guest #1' | 'guest-1' |
| 'café' | 'caf' |
| 'booking system' | 'booking-system' |
| text |
|---|
| '---' |
| ' ' |
| '' |
| '###' |
| same_definition | outcome |
|---|---|
| True | one shared term |
| False | refused |
| canonical | lowered |
|---|---|
| 'Booking Request' | 'booking request' |
| 'LLM Call' | 'LLM call' |
| 'Check-In' | 'check-in' |
| 'Plan B' | 'plan B' |
| 'E-Mail' | 'e-mail' |
| 'LLM-Based Search' | 'LLM-based search' |
| 'iPhone' | 'iPhone' |
| 'McDonald' | 'McDonald' |
| canonical | forms | reading |
|---|---|---|
| 'Room' | 's' | 'Rooms' |
| 'Room' | 'l.s' | 'rooms' |
| 'Room' | 's.l' | 'rooms' |
| 'Box' | 'l.s' | 'boxes' |
| 'Category' | 'l.s' | 'categories' |
| 'API Key' | 'l.s' | 'API keys' |
| 'API' | 's' | 'APIs' |
| 'book' | 's' | 'books' |
| slots | kind |
|---|---|
| actor | actor |
| verb | activity |
| noun | object |
| actor, noun | actor |
| slots |
|---|
| verb, actor |
| verb, noun |
| declared | slot | outcome |
|---|---|---|
| actor | actor | kept |
| activity | actor | refused |
| object | actor | refused |
| actor | verb | refused |
| activity | verb | kept |
| object | verb | refused |
| actor | noun | kept |
| activity | noun | refused |
| object | noun | kept |
| document | Markdown document | columns | message |
|---|---|---|---|
| no pipe table | {} | found no Markdown pipe table | |
| one pipe table | {'term_column': 'Nope'} | column 'Nope' not found | |
| one pipe table | {'definition_column': 5} | column index 5 is out of range | |
| document | Markdown document | rows |
|---|---|---|
| a table in a blockquote | [('Quoted', 'yes')] | |
| a table in an indented code block | [('Real', 'yes')] | |
| a separator row narrower than its header | [('Real', 'yes')] | |
| a data row narrower than its header | [('Short', '')] | |
| a table in a fenced code block | [('Real', 'yes')] | |
| a pipe line with no separator row | [('Real', 'yes')] | |
| column | cell | plain |
|---|---|---|
| term | **Scenario** | Scenario |
| term | *Step* | Step |
| term | `given` | given |
| term | work_object | work_object |
| term | `a*b*c` | a*b*c |
| term | __Scenario__ | __Scenario__ |
| kind | **Actor** | Actor |
| kind | `activity` | activity |
PytestGivenWarning is raised, not an error@scenario, so a suite can filter itpytest.raises
| phase_name | outcome |
|---|---|
| when | nested |
| given | refused |
| then | refused |
@scenario marks the test function without wrapping it
| label_kind |
|---|
| deferred-template |
| t-string |
| not-a-string |
Template narration is refused in a test body
Template| phase_name |
|---|
| given |
| when |
| then |
| written |
|---|
| 2 |
| cancel |
| [1, 2] |
| kind | position | outcome |
|---|---|---|
| actor | 0 | accepted |
| actor | 1 | refused |
| actor | 2 | accepted |
| object | 0 | refused |
| object | 1 | refused |
| object | 2 | accepted |
| activity | 0 | refused |
| activity | 1 | accepted |
| activity | 2 | refused |
| None | 0 | accepted |
| None | 1 | accepted |
| None | 2 | accepted |
| position |
|---|
| 0 |
| 1 |
| 2 |
| name |
|---|
| '' |
| ' cancel' |
| 'cancel ' |
Template parses a bare placeholder
Template with one placeholderTemplate substitutes parametrize values
Template referencing a parametrize columnTemplate accepts bare identifiers only
Template is built from it| case ID | text |
|---|---|
| attribute | count={obj.attr} |
| indexing | {d[key]} |
| expression | {x + 1} |
| name | called_with | term_id | display |
|---|---|---|---|
| Guest | None | guest | Guest |
| Guest | Alice | guest | Alice |
| Room | None | room | Room |
| Room | Deluxe Suite | room | Deluxe Suite |
| search | None | search | search |
| search | searches for | search | searches for |
Template placeholdercitations update rewrites a stale citation to its target's glyph, text and summary
checkout has a passed and an xfailed scenariocitations update refuses a document that changed while it ran
[a] and [c] of test_pour group into one scenario[c]test_pourcitations update repoints the citation of a renamed test by its unchanged scenario title
test_pay was renamed test_pay_by_card, still titled "Pay by card"test_payupdate fixes, naming test_pay_by_cardtest_pay_by_card--report-path places the report
examples/r.htmlguide/doc.md linking ../examples/r.html--report-path--covering keeps each report link whose target counts the scenario, and each it cannot rule out
test_pay is tagged checkout/card and in a story, test_refund tagged checkout/refundtest_pay| link | kept |
|---|---|
| ✅ [Pay by card](https://example.org/report.html#scenario=t.py::test_pay) | True |
| [paying](https://example.org/report.html#scenario=t.py::test_pay) | True |
| ✅ [Refund](https://example.org/report.html#scenario=t.py::test_refund) | False |
| ✅ [checkout/card](https://example.org/report.html#tag=checkout/card) (1 ✅) | True |
| ✅ [checkout](https://example.org/report.html#tag=checkout) (2 ✅) | True |
| ✅ [checkout/refund](https://example.org/report.html#tag=checkout/refund) (1 ✅) | False |
| ✅ [s](https://example.org/report.html#view=stories&story=s) (1 ✅) | True |
| ✅ [Gone](https://example.org/report.html#scenario=t.py::test_gone) | True |
| ✅ [search](https://example.org/report.html#q=pay) | True |
citations update writes a narrated citation's body from the report
citations check reports a narrated citation whose body differs from the report
update leaves
checkout and covers the story checkoutupdate cannot fix| target | document |
|---|---|
| tag | |
| story | |
<details> block citing the report in any other shape is a mistyped citation finding, never skipped
<details> block cites the report with {shape}| shape | document | reason |
|---|---|---|
| an anchor with a class | its <a> takes attributes besides href | |
| a single-quoted href | its href is not in double quotes | |
| no closing tag | no </details> closes it | |
| no blank line above it, below another one | a blank line must separate it from the HTML above it | |
citations update fills its body
citations update adds markdown="1" to a narrated citation's opening tag, keeping its other attributes
| opening | expected |
|---|---|
| <details open> | <details markdown="1" open> |
| <details open markdown="0"> | <details open markdown="1"> |
| <details markdown='block'> | <details markdown="1"> |
| <details markdown> | <details markdown="1"> |
| <details title="see markdown here"> | <details markdown="1" title="see markdown here"> |
| container | document | updated document |
|---|---|---|
| list item | ||
| blockquote | ||
passif| phase | step body | messages |
|---|---|---|
| given | ["assert inside given 'a stocked machine'"] | |
| when | ["assert inside when 'a stocked machine'"] | |
| then | [] | |
| steps_naming | covered |
|---|---|
| [['guest', 'search', 'room']] | True |
| [['guest', 'search'], ['room']] | False |
| [['guest'], ['guest', 'search', 'room']] | True |
| case ID | scenario_pins | step_pins | covered |
|---|---|---|---|
| nothing-pinned | None | None | [1] |
| step-pinned | None | [2] | [2] |
| scenario-pinned | [] | None | [] |
| both-pinned | [] | [2] | [2] |
| scenario-pins-elsewhere | [2] | None | [2] |
| scenario-and-step-pinned | [1] | [2] | [1, 2] |
| term_ids | eligible |
|---|---|
| ['guest', 'room'] | True |
| ['guest', 'guest'] | False |
| ['guest'] | False |
| [] | False |
| conversion | repr_column |
|---|---|
| 'r' | True |
| 'a' | True |
| 's' | False |
| None | False |
** markers enclose a term ref| first_status | second_status | header | Rendered Markdown |
|---|---|---|---|
| passed | passed | | coin | | |
| skipped | skipped | | coin | | |
| failed | failed | | coin | | |
| passed | skipped | | coin | | | |
| passed | failed | | coin | | | |
coverage lists every sentence once| value | template |
|---|---|
| vscode | vscode://file/{path}:{line} |
| cursor | cursor://file/{path}:{line} |
| zed | zed://file/{path}:{line} |
| pycharm | pycharm://open?file={path}&line={line} |
| https://github.com/o/r/blob/{sha}/{relpath}#L{line} | https://github.com/o/r/blob/{sha}/{relpath}#L{line} |
| none | None |
GITHUB_REPOSITORY over the git remote
| pinned | untracked |
|---|---|
| False | True |
| True | False |
| statuses | status | reason |
|---|---|---|
| passed, failed, skipped | failed | None |
| xfailed, failed | failed | None |
| passed, xfailed | xfailed | planned |
| skipped, xfailed | xfailed | planned |
| skipped, passed | passed | None |
| skipped, skipped | skipped | None |
| case ID | status | first | second | shared |
|---|---|---|---|---|
| skipped-different | skipped | needs a database | needs a service | None |
| skipped-shared | skipped | needs a database | needs a database | needs a database |
| xfailed-different | xfailed | flaky | slow | None |
| xfailed-shared | xfailed | flaky | flaky | flaky |
| case ID | retries | failed steps |
|---|---|---|
| stops-early | False | |
| parts-from-the-baseline | True | |
--given-lint pass that checks recorded scenarios against the Lint rule catalog. It enforces the structural subset of the narration conventions — it cannot check whether a Step's text is semantically true.@scenario. Tests without the mark stay out of the report.given, when, or then. A step has exactly one phase./ nests it: ticket/ABC-123 sits under ticket.param (a parametrize input), a derived (a narrated value that varies across cases) or an attachment (an attachment whose payload varies).given Step. A fixture cannot narrate when or then.runtime rule reads the recorded scenarios; an ast rule parses the step bodies' source.@scenario(group_parametrized=False) declines the merge, so each case lives on as its own scenario.when action and its then outcome as two sibling steps. Used mainly to narrate an expected raise, so the action and its outcome stay distinct steps.touching-edges), as the terminal prints it. Custom when it is more than its values' generated parts, as from pytest.param(..., id=...) or ids=.given(...) in a test parameter's Annotated[...] type: def test(room: Annotated[int, given('a room')]). On a parametrize value or a Plain fixture it adds a childless given step; on a Step fixture it replaces the fixture's root label and its pins. Only given is allowed, and a Template in it may only hold a bare parametrize column.tests/test_x.py::test_y[a-b]).price * 1.2). One that varies becomes a derived column instead.✅ [title](<report URL>#scenario=…). A tag or story citation adds a summary after it, (5 ✅ · 2 🔵). A target the Report lacks reads ❓.pytest-given citations check reports on one Report link: its kind (stale, missing, failed, mistyped, …), the document location and a message.light, dark, or auto (follow the viewer's system).off, warn or error. Only error fails the run, warn reports in the terminal summary, and an off rule is not evaluated at all.g('foo') and g['foo'] on a code glossary return, and a file glossary lookup of a row with no declared kind. Kind inference settles it later.g.actor(...), g('foo'), g['Guest'], a captured guest = ...). It is what steps, scenario titles and sentences interpolate, in one of four surface forms: bare (room — the canonical display), .l (room.l — capitalized words lowercased, acronyms kept), .s (room.s — the S-form), or called (room('Deluxe Suite') — an instance on an Actor or Work Object, an inflection on an Activity). .l and .s also apply to a called form and chain (room.l.s reads rooms). Each form renders as a term ref. A story hands out a sentence handle the same way: book_a_room['cancel'] by name or book_a_room[3] by number, which pins= takes..s handle form: the plural of an Actor or Work Object (rooms), the third person singular of an Activity (books). It adds -s to the last word, -es after s, x, z, ch or sh, and turns a consonant + y into -ies, but an acronym takes a plain -s (APIs); anything else, such as people or checks in, needs the called form. An S-form reference, in any case, is a reference to the term itself — not an instance or an inflection.search('searches for') records searches for as a surface form of the canonical search.guest('Alice') is an instance of the Guest actor).@scenario(stories=...) names the stories a scenario is narration-matched against; a pin (pins= on @scenario or on given/when/then) binds sentences explicitly, in any story, whether stories= names it or not.pins= is recorded as, the way a term handle in narration is recorded as a term ref: a reference to a story and a sentence number. A pin binds explicitly and replaces narration matching — a step pin for that step, a scenario pin (@scenario(pins=...)) for every step of the scenario, which then covers its own pins plus its steps'. pins=[] pins nothing but still opts out of narration matching. A pin reaches under-anchored sentences too.