fix: load the pack modules above 3.8 in tests

The packs imports moved to module level in test_install_selection and
test_install_tui. They pull core.cli, which stops below Python 3.9, so
the 3.8 screen test step exited at import.
This commit is contained in:
Abdessamad Derraz committed 2026-11-18 18:56:46 +01:00
1 parent 825c527d11
commit d50dfc36e2
2 files changed
+11 -8

No files matched your search

+6 -4
View File
@@ -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")
+5 -4
View File
@@ -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)