Repository navigation
fix: keep artifacts when a fixture fails during teardown - #330
Merged
Pavel Feldman (pavelfeldman) merged 2 commits intoOct 8, 2026
Merged
Conversation
Pavel Feldman (pavelfeldman)
added this pull request to stack #335
October 7, 2026 23:05
Pavel Feldman (pavelfeldman)
force-pushed
the
fix-117-artifacts-on-teardown-failure
branch
from
October 8, 2026 01:32
186d1ed to
bd65cd1
Compare
Pavel Feldman (pavelfeldman)
force-pushed
the
fix-117-artifacts-on-teardown-failure
branch
from
October 8, 2026 01:42
bd65cd1 to
c090b7b
Compare
With --tracing/--video retain-on-failure or --screenshot only-on-failure, artifacts were discarded when a user fixture (e.g. one that uses `page`) failed during teardown: the recorder decided in its own fixture teardown, which runs before such failures are reported. Videos are now copied out of Playwright in the fixture teardown, and when the test has not failed yet, keeping or discarding the artifacts is deferred to pytest_runtest_makereport for the teardown report. The session temp folder is now cleaned up at the end of the run, since the last test's teardown report comes after session fixtures are torn down. Fixes #117
…ests skipped from a fixture, keep the fixture's own teardown error, test the artifact error path
Pavel Feldman (pavelfeldman)
force-pushed
the
fix-117-artifacts-on-teardown-failure
branch
from
October 8, 2026 01:43
c090b7b to
7cc6e8f
Compare
Pavel Feldman (pavelfeldman)
deleted the
fix-117-artifacts-on-teardown-failure
branch
October 8, 2026 02:09
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With
--tracing/--video retain-on-failureor--screenshot only-on-failure, artifacts were discarded when a user fixture failed during teardown (e.g. alogged_in(page)fixture whose logout step raises). The recorder decided in its own fixture teardown, which runs before such failures are reported. Setup failures already kept artifacts.awaitin the asyncio plugin) still happens there. Under--video retain-on-failurethis is one extra file copy per page for every test, passing ones included; before, passing tests only deleted the video.pytest_runtest_makereportfor the teardown report, which reflects failures from every fixture.pytest.skip()during setup) no longer counts as failed. Before,retain-on-failurekept atest-failed-1.pngand a trace for it.pytest_runtest_makereportwrapper now runstrylast, sopytest_runtest_makereporthooks in conftest.py and in other plugins see the outcome it sets on the teardown report.config.add_cleanup, because the last test's teardown report comes after session fixtures are torn down.Tests: fixtures failing in setup and in teardown keep the screenshot, trace and video, a fixture that skips keeps nothing, and a failing
shutil.moveproduces teardown errors with both messages (sync + async).Fixes #117
Stack created with GitHub Stacks CLI • Give Feedback 💬