# SPDX-License-Identifier: MIT """Shared fixtures: ROMs and BIOS images are read in place and skipped when absent. The dumps are found below ``$NO_INTRO_DIR`` and the BIOS below ``$MAME_ROMPATH`` (src/a7800_python/romsets.py); a test that needs one skips, naming the unset variable, so the default suite runs anywhere. """ from __future__ import annotations import os import zipfile from pathlib import Path import pytest from a7800_python.romsets import DUMPS_2600, LICENSED_7800 _NOINTRO = os.environ.get("NO_INTRO_DIR", "") NOINTRO = Path(_NOINTRO or "NO_INTRO_DIR-is-unset") # read_zip skips before using it LICENSED = NOINTRO / LICENSED_7800 A2600 = NOINTRO / DUMPS_2600 ROOT = Path(__file__).resolve().parents[1] def read_zip(path: Path) -> bytes: if not _NOINTRO: pytest.skip("NO_INTRO_DIR is not set: export it as the folder that holds the No-Intro sets") if not path.exists(): pytest.skip(f"not on this machine: {path}") with zipfile.ZipFile(path) as z: return z.read(z.infolist()[0]) @pytest.fixture def ntsc_bios() -> bytes: from a7800_python.machine import NTSC from a7800_python.system import find_bios bios = find_bios(NTSC) if bios is None: pytest.skip("no NTSC BIOS image found by hash below $MAME_ROMPATH (set it?)") return bios @pytest.fixture def pal_bios() -> bytes: from a7800_python.machine import PAL from a7800_python.system import find_bios bios = find_bios(PAL) if bios is None: pytest.skip("no PAL BIOS image found by hash below $MAME_ROMPATH (set it?)") return bios