refactor: split this round's fixes into small helpers

This commit is contained in:
Abdessamad Derraz committed 2026-10-06 11:16:06 +02:00
1 parent 6748982d94
commit eb8c7e5267
15 files changed
+218 -157

No files matched your search

+1 -1
View File
@@ -576,7 +576,7 @@ class SchemaFormatsAreChecked(unittest.TestCase):
@unittest.skipUnless(HAS_JSONSCHEMA, "validating a schema needs jsonschema")
def test_a_missing_checker_is_named(self):
import validate_schemas
import validate_schemas # noqa: PLC0415
empty = mock.Mock(checkers={})
with mock.patch.object(validate_schemas, "FormatChecker", return_value=empty):
+2 -3
View File
@@ -10,6 +10,7 @@ import re
import sys
import unittest
from pathlib import Path
from unittest import mock
REPO_ROOT = Path(__file__).resolve().parent.parent
sys.path.insert(0, str(REPO_ROOT / "scripts"))
@@ -37,11 +38,9 @@ class CoverageReadsTheGivenProfiles(unittest.TestCase):
platform coverage, which read ./emulators whatever was given."""
def test_the_directory_reaches_verify(self):
from unittest import mock # noqa: PLC0415
seen: list[str] = []
def fake_verify(config, db, emulators_dir, **_kwargs):
def fake_verify(_config, _db, emulators_dir, **_kwargs):
seen.append(emulators_dir)
return {"status_counts": {}, "total_files": 0, "undeclared_files": [], "details": []}
+4 -8
View File
@@ -19,6 +19,10 @@ REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
from exporter.baseline import NativeFile, NativeSystem, build_native_model # noqa: E402
from exporter.bizhawk_exporter import Exporter as BizHawk # noqa: E402
from exporter.misterfpga_exporter import Exporter as Mister # noqa: E402
from exporter.romm_exporter import Exporter as Romm # noqa: E402
from scraper.emudeck_scraper import FUNCTION_HASH_MAP # noqa: E402
from exporter.emudeck_exporter import Exporter as EmuDeck # noqa: E402
from exporter.retrobat_exporter import Exporter as RetroBat # noqa: E402
from exporter.retrodeck_exporter import Exporter as RetroDeck # noqa: E402
@@ -130,8 +134,6 @@ class EmuDeckWritesItsCorrections(unittest.TestCase):
SCRIPT = "checkPS1BIOS(){\n local hashes=(%s)\n}\n"
def _systems(self, corrected: NativeFile, other: NativeFile) -> dict:
from scraper.emudeck_scraper import FUNCTION_HASH_MAP
system_id = FUNCTION_HASH_MAP["checkPS1BIOS"]
corrected.native_system = other.native_system = system_id
return {system_id: NativeSystem(system_id, files=[corrected, other])}
@@ -168,8 +170,6 @@ class EmuDeckWritesItsCorrections(unittest.TestCase):
class BizHawkCountsWhatItWrites(unittest.TestCase):
def test_an_ambiguous_name_is_not_counted(self):
from exporter.bizhawk_exporter import Exporter as BizHawk
sha_a, sha_b, sha_c = "a" * 40, "b" * 40, "c" * 40
first = NativeFile("bios.bin", "bios.bin", "S1", platform={"sha1": sha_a},
truth={"sha1": sha_b}, corrections=["sha1"])
@@ -183,8 +183,6 @@ class BizHawkCountsWhatItWrites(unittest.TestCase):
class MisterCountsWhatItWrites(unittest.TestCase):
def test_a_path_the_database_lacks_is_not_counted(self):
from exporter.misterfpga_exporter import Exporter as Mister
held = NativeFile("boot.rom", "NES/boot.rom", "nes", platform={"md5": A},
truth={"md5": B}, corrections=["md5"])
absent = NativeFile("boot.rom", "SNES/boot.rom", "snes", platform={"md5": A},
@@ -260,8 +258,6 @@ class OneFileOneIdentity(unittest.TestCase):
class RommKeepsItsOwnKeys(unittest.TestCase):
def test_a_same_named_addition_does_not_replace_their_entry(self):
"""fbneo's 480-byte boot.bin overwrote RomM's Dreamcast boot.bin."""
from exporter.romm_exporter import Exporter as Romm
theirs = NativeFile("boot.bin", "dc/boot.bin", "dc",
platform={"size": 2097152, "md5": A})
ours = NativeFile("boot.bin", "fbneo/boot.bin", "dc",
+3 -1
View File
@@ -2558,7 +2558,9 @@ class TestBumpCommit(unittest.TestCase):
text = self.path.read_text(encoding="utf-8")
self.path.write_text(
"source_commit:\n standalone: \"aaa\"\n libretro: \"bbb\"\n"
+ "\n".join(l for l in text.splitlines() if not l.startswith("source_commit"))
+ "\n".join(
line for line in text.splitlines() if not line.startswith("source_commit")
)
+ "\n",
encoding="utf-8",
)
+3 -5
View File
@@ -9,7 +9,9 @@ from pathlib import Path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "scripts"))
import region
import common # noqa: E402
import region # noqa: E402
from packextras import emulator_region_drops # noqa: E402
class TestVocabulary(unittest.TestCase):
@@ -647,10 +649,6 @@ class RegionalRequestsKeepWhatTheCodeLoads(unittest.TestCase):
)
def test_each_request_keeps_its_file(self):
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "scripts"))
import common
from packextras import emulator_region_drops
profiles = common.load_emulator_profiles(
os.path.join(os.path.dirname(__file__), "..", "emulators")
)