From 3cec62e40872ead987e5212827f7b7657c587ac1 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Mon, 15 Apr 2024 21:49:15 +0200 Subject: [PATCH] fix: improve video naming (#217) --- pytest_playwright/pytest_playwright.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pytest_playwright/pytest_playwright.py b/pytest_playwright/pytest_playwright.py index 6cbe01e..306852a 100644 --- a/pytest_playwright/pytest_playwright.py +++ b/pytest_playwright/pytest_playwright.py @@ -297,15 +297,14 @@ def context( failed and video_option == "retain-on-failure" ) if preserve_video: - for page in pages: + for i, page in enumerate(pages): video = page.video if not video: continue try: - video_path = video.path() - file_name = os.path.basename(video_path) + video_name = "video.webm" if len(pages) == 1 else f"video-{i+1}.webm" video.save_as( - path=_build_artifact_test_folder(pytestconfig, request, file_name) + path=_build_artifact_test_folder(pytestconfig, request, video_name) ) except Error: # Silent catch empty videos.