Skip to content

Commit

Permalink
fix: clean up videos after each test
Browse files Browse the repository at this point in the history
  • Loading branch information
mxschmitt committed Apr 16, 2024
1 parent 2d5a080 commit 6389ab6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pytest_playwright/pytest_playwright.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,14 @@ def did_finish_test(self, failed: bool) -> None:
except Error:
# Silent catch empty videos.
pass
else:
for page in self._all_pages:
# Can be changed to "if page.video" without try/except once https://github.com/microsoft/playwright-python/pull/2410 is released and widely adopted.
if video_option in ["on", "retain-on-failure"]:
try:
page.video.delete()
except Error:
pass

def on_did_create_browser_context(self, context: BrowserContext) -> None:
context.on("page", lambda page: self._all_pages.append(page))
Expand Down

0 comments on commit 6389ab6

Please sign in to comment.