From ef99541352b307411dbc15c627e50f95de30cc71 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Tue, 10 Oct 2023 18:36:31 +0200 Subject: [PATCH] fix: use best-effort artifacts folder removal (#191) --- pytest_playwright/pytest_playwright.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pytest_playwright/pytest_playwright.py b/pytest_playwright/pytest_playwright.py index f5c8ec4..7fe0fb0 100644 --- a/pytest_playwright/pytest_playwright.py +++ b/pytest_playwright/pytest_playwright.py @@ -220,7 +220,12 @@ def browser(launch_browser: Callable[[], Browser]) -> Generator[Browser, None, N browser = launch_browser() yield browser browser.close() - artifacts_folder.cleanup() + try: + # On Windows, files can be still in use. + # https://github.com/microsoft/playwright-pytest/issues/163 + artifacts_folder.cleanup() + except (PermissionError, NotADirectoryError): + pass @pytest.fixture