Skip to content

python(fix): teardown failure on the last test, and combined parametrize axis nesting - #691

Merged
alexluck-sift merged 5 commits into
mainfrom
al/python/fix/parameterize-test-results
Jul 28, 2026
Merged

python(fix): teardown failure on the last test, and combined parametrize axis nesting#691
alexluck-sift merged 5 commits into
mainfrom
al/python/fix/parameterize-test-results

Conversation

@alexluck-sift

@alexluck-sift alexluck-sift commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Two independent fixes to the pytest plugin's report tree.

Teardown failure on the last test was never uploaded. pytest tears down the session-scoped report_context fixture during the final item's teardown phase but reports that outcome afterwards, so the report status was computed before the failure was known and its log entry was written after the import worker stopped reading. A run whose last test failed in teardown showed fully green. finalize is now split out of __exit__ and deferred via a constructor flag, so the plugin calls it from pytest_sessionfinish. Late failures also propagate up the ancestor chain, correcting already-closed ancestors from PASSED to FAILED.

Combined parametrize axes nested once per argname. @pytest.mark.parametrize("a,b,c", cases, ids=NAMES) is one axis in pytest, but the plugin rendered one step per argname and discarded ids=, so function-object values produced labels carrying heap addresses. Axes are now grouped by their mark: one axis, one step, labelled with its ID. This changes step names and tree depth, so reports from before and after will not group together.

182 tests passing in _tests/pytest_plugin, up from 177. Both fixes have regression tests verified to fail against the pre-fix code. One existing test asserted the old per-argname behavior and was replaced.

@alexluck-sift
alexluck-sift requested a review from ian-sift July 28, 2026 01:02
@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Python docs preview: https://sift-stack.github.io/sift/python/pr-691/

Deployed from 1394423. The link may take up to a minute to become live as GitHub Pages propagates.

@alexluck-sift alexluck-sift changed the title Python(fix): pytest parameterize and teardown python(fix): teardown failure on the last test, and combined parametrize axis nesting Jul 28, 2026
StatusWrites is a module-level alias, so it is evaluated at runtime and
builtin generics are not subscriptable before 3.9. Spell it with
typing.List/Tuple.

Four new tests reused the inner module and function name test_comb.
steps.parametrize_parents is a module-global keyed by nodeid and its reset
fixture is opt-in, so identical keys collided across tests once the order
was shuffled. Give each a unique name, and assert the ancestor chain over
every leaf rather than a fixed index.
@alexluck-sift
alexluck-sift merged commit 950e646 into main Jul 28, 2026
26 checks passed
@alexluck-sift
alexluck-sift deleted the al/python/fix/parameterize-test-results branch July 28, 2026 03:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants