From 26c45da3187829b3c0ab06d7aaed17a81d9bc0b5 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Sat, 21 Nov 2026 00:08:06 +0100 Subject: [PATCH] fix: keep the screen tests importable on 3.8 tests/sources.py used functools.cache (3.9) and test_install_selection imported resolve.regions, which reaches core.cli and its 3.9 floor exit. Both broke python3.8 -m unittest tests.test_install_tui in Validation. ruff UP033 asks for functools.cache under target py39, so the modules the 3.8 run imports take the same UP exemption as installer/. --- pyproject.toml | 7 +++++++ tests/sources.py | 4 ++-- tests/test_install_selection.py | 5 +++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d6e676902..103074c95 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -107,5 +107,12 @@ max-returns = 10 [tool.ruff.lint.per-file-ignores] "install.py" = ["UP"] "installer/*.py" = ["UP"] +# The full-screen tests and the modules they import run under the 3.8 floor too. +"tests/__init__.py" = ["UP"] +"tests/sources.py" = ["UP"] +"tests/netguard/*.py" = ["UP"] +"tests/test_install_tui.py" = ["UP"] +"tests/test_install_app.py" = ["UP"] +"tests/test_install_selection.py" = ["UP"] # Shell fixtures inside string literals keep the tabs the real files have. "tests/test_launchers_*.py" = ["E101"] diff --git a/tests/sources.py b/tests/sources.py index 17abd6efb..252784e35 100644 --- a/tests/sources.py +++ b/tests/sources.py @@ -8,7 +8,7 @@ command keeps its options, the packages keep the rest. from __future__ import annotations import ast -from functools import cache +from functools import lru_cache from pathlib import Path SCRIPTS = Path(__file__).resolve().parents[1] / "scripts" @@ -129,7 +129,7 @@ def _add_argument_flags(tree: ast.AST) -> set[str]: } -@cache +@lru_cache(maxsize=None) def declared_options(source: str) -> frozenset[str]: """The long options a script's source declares: its add_argument calls and the shared ones core.cli's add_repo_inputs and add_emulator_selection add.""" diff --git a/tests/test_install_selection.py b/tests/test_install_selection.py index 1648ce75d..e25d21c6a 100644 --- a/tests/test_install_selection.py +++ b/tests/test_install_selection.py @@ -32,11 +32,12 @@ 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. +# build scripts stop below 3.9 (core.cli), so their modules load only above +# that floor. if sys.version_info >= (3, 9): + from resolve import regions as resolve_regions from packs import archive, coverage, platformpack from packs import manifest as packs_manifest