diff --git a/tests/test_install_selection.py b/tests/test_install_selection.py index bac0ba9a4..c3849750b 100644 --- a/tests/test_install_selection.py +++ b/tests/test_install_selection.py @@ -28,16 +28,18 @@ import sys import tempfile import threading import unittest -from packs import archive -from packs import manifest as packs_manifest -from packs import platformpack -from packs import coverage from unittest import mock from pathlib import Path from model import region from resolve import regions as resolve_regions +# The screen tests run under 3.8 and import this module for its fakes. The +# pack builder stops below 3.9, so its modules load only above that floor. +if sys.version_info >= (3, 9): + from packs import archive, coverage, platformpack + from packs import manifest as packs_manifest + REPO_ROOT = Path(__file__).resolve().parent.parent _spec = importlib.util.spec_from_file_location("install", REPO_ROOT / "install.py") diff --git a/tests/test_install_tui.py b/tests/test_install_tui.py index 309b5d9f6..98badd726 100644 --- a/tests/test_install_tui.py +++ b/tests/test_install_tui.py @@ -42,8 +42,6 @@ from pathlib import Path, PurePosixPath, PureWindowsPath from unittest import mock import install -from packs import archive as packs_archive -from packs import emulatorpack from tests.test_install_app import make_card from tests.test_install_selection import FakeRepository, _QuietHandler from tests.netguard import module_guard @@ -16168,14 +16166,17 @@ class EmulatorChoiceMatchesTheEmulatorPack(unittest.TestCase): # The builder's floor: install.py alone keeps 3.8. raise unittest.SkipTest("generate_pack.py needs Python 3.9 or newer") from core.ziptools import build_zip_contents_index + from packs import archive as packs_archive + from packs import emulatorpack + cls.packs_archive, cls.emulatorpack = packs_archive, emulatorpack cls.db = json.loads(db_path.read_text(encoding="utf-8")) cls.zip_contents = build_zip_contents_index(cls.db) cls.by_path = {entry["path"]: sha1 for sha1, entry in cls.db["files"].items()} def pack(self, emulator: str) -> dict[str, str]: - record = packs_archive.PackRecord() + record = self.packs_archive.PackRecord() with contextlib.redirect_stdout(io.StringIO()): - emulatorpack.generate_emulator_pack( + self.emulatorpack.generate_emulator_pack( [emulator], str(REPO_ROOT / "emulators"), self.db, str(REPO_ROOT / "bios"), str(REPO_ROOT / "tmp"), zip_contents=self.zip_contents, offline=True, record=record)