Files
libretro/tests/test_bios_companions.py
T
Abdessamad Derraz 4231902a6c docs: write prose without dashes or semicolons
Profiles, the wiki, comments, docstrings, command output and schema descriptions carried em-dashes, clause-joining semicolons, unicode arrows, box-drawing banners and check-mark glyphs. Each sentence was rewritten rather than having its character swapped. Hashes, paths, source_ref values and every cited file:line are unchanged, which a comparison of each parsed profile against the previous revision confirms.

validate_pr comments now say PASS and FAIL in words, and source_ref values in a profile's structured blocks render as code. test_prose_style fails if any of these comes back, in tracked files or in the generated site.
2026-10-19 06:47:31 +02:00

56 lines
2.1 KiB
Python

"""Companions travel with the BIOS image they belong to.
PCSX2 opens <bios>.rom1 or <stem>.rom1, and nvm and mec the same way. Its
profile named them rom1.bin, ROM2.BIN and EROM.BIN, names the code never
opens. ROM2.BIN found a misfiled Galaksija ROM inside the PS2 folder, and a
4 MB size bound then swept GameIndex.yaml and cheat archives to the root of
the Batocera BIOS folder.
"""
from __future__ import annotations
import sys
import unittest
from pathlib import Path
import yaml
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
from packextras import _companion_extensions, _companions # noqa: E402
class Companions(unittest.TestCase):
PROFILE = {"files": [
{"name": "ps2-0230a-20080220.bin"},
{"name": "ps2-0230a-20080220.rom1"},
{"name": "ps2-0230a-20080220.nvm"},
{"name": "GameIndex.yaml"},
]}
def test_extensions_come_from_entries_named_after_the_bios(self):
self.assertEqual(
_companion_extensions(self.PROFILE, "ps2-0230a-20080220.bin"), {"rom1", "nvm"}
)
def test_only_files_named_after_the_image_follow_it(self):
files_db = {
"a": {"path": "bios/PS2/SCPH-70004.ROM1", "name": "SCPH-70004.ROM1"},
"b": {"path": "bios/PS2/scph70004.bin.nvm", "name": "scph70004.bin.nvm"},
"c": {"path": "bios/PS2/GameIndex.yaml", "name": "GameIndex.yaml"},
"d": {"path": "bios/Other/SCPH-70004.ROM1", "name": "SCPH-70004.ROM1"},
}
found = _companions("bios/PS2/SCPH-70004.BIN", "SCPH-70004.BIN", {"rom1", "nvm"}, files_db)
self.assertEqual([sha for sha, _ in found], ["a"])
def test_pcsx2_profiles_name_no_free_standing_companion(self):
for name in ("pcsx2", "pcsx2-legacy"):
profile = yaml.safe_load((REPO_ROOT / "emulators" / f"{name}.yml").read_text())
names = {str(f.get("name", "")).lower() for f in profile.get("files", [])}
with self.subTest(profile=name):
self.assertFalse({"rom1.bin", "rom2.bin", "erom.bin"} & names)
if __name__ == "__main__":
unittest.main()