From fa9ec2d80e668a9b8db985c4642acd3cac9e86ec Mon Sep 17 00:00:00 2001 From: mike8699 Date: Sun, 29 Dec 2024 16:20:16 -0500 Subject: [PATCH] Don't crash if failing to delete recording MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Windows ¯\_(ツ)_/¯ --- tests/desmume/conftest.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/desmume/conftest.py b/tests/desmume/conftest.py index c87ea283..31ffee6b 100644 --- a/tests/desmume/conftest.py +++ b/tests/desmume/conftest.py @@ -1,5 +1,6 @@ from collections.abc import Generator from enum import Enum +import logging import os from pathlib import Path import shutil @@ -14,6 +15,8 @@ from .emulator_utils import AbstractEmulatorWrapper from .melonds import MelonDSWrapper +logger = logging.getLogger(__name__) + def pytest_addoption(parser): parser.addoption('--desmume', action='store_true', default=False, help='Enable DeSmuME tests') @@ -33,7 +36,10 @@ def test_teardown(rom_path: Path, request): # If the test didn't fail, just delete the recording if tests_failed_before == request.session.testsfailed: - video_path.unlink(missing_ok=True) + try: + video_path.unlink(missing_ok=True) + except PermissionError: + logger.warning(f'Failed to delete video recording {video_path}') return for file in video_path.parent.iterdir():