From 1077d771258c8094de2058e3b16372469b158274 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Wed, 4 Nov 2026 04:47:01 +0100 Subject: [PATCH] fix: reset console pages in the index tests A Sony fixture split by console recorded its pages in the shared map, and the index tests that ran after it linked PlayStation to the split page. They now start from an empty map, and the fixture clears it when done. --- tests/test_site_r2_emulators.py | 3 +++ tests/test_site_r2_systems.py | 4 +++- tests/test_site_r4_systems.py | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/test_site_r2_emulators.py b/tests/test_site_r2_emulators.py index 6cf729eed..47aeed53b 100644 --- a/tests/test_site_r2_emulators.py +++ b/tests/test_site_r2_emulators.py @@ -165,6 +165,9 @@ class TheSummaryLineIsProse(unittest.TestCase): class TheIndexNamesEmulatorsAndSystems(unittest.TestCase): def test_columns_and_counts(self): + # Pages another test split off would send the console elsewhere. + siterender.reset_console_pages() + self.addCleanup(siterender.reset_console_pages) saved = dict(siterender._system_page_map) self.addCleanup(siterender.set_system_page_map, saved) siterender.set_system_page_map({"sony-playstation": ("sony", "PlayStation")}) diff --git a/tests/test_site_r2_systems.py b/tests/test_site_r2_systems.py index 1b985c79d..c24ec2212 100644 --- a/tests/test_site_r2_systems.py +++ b/tests/test_site_r2_systems.py @@ -128,7 +128,7 @@ class TheConsoleBiosComesFirst(unittest.TestCase): self.assertEqual(gs._start_with([_file("a.bin", "a")], _consumers({})), []) def test_the_page_carries_the_line_under_the_console(self): - # Sega keeps its consoles as sections; Sony gives each a page. + # Sega keeps its consoles as sections. Sony gives each a page. page = gs.generate_system_page("Sega", {"Saturn": self.files}, self.required_only()) heading = page.index("## Saturn") self.assertLess(heading, page.index("**Start with**")) @@ -254,6 +254,8 @@ class TheSystemsIndexListsConsoles(unittest.TestCase): be known to be under Sony.""" def test_one_row_per_console_by_its_name(self): + gs.reset_console_pages() + self.addCleanup(gs.reset_console_pages) groups = { "Sony": {"PlayStation": [_file("a.bin", "a")], "PlayStation 2": [_file("b.bin", "b")]}, "Other": {"ScummVM": [_file("c.bin", "c")]}, diff --git a/tests/test_site_r4_systems.py b/tests/test_site_r4_systems.py index 502815e68..962ff4565 100644 --- a/tests/test_site_r4_systems.py +++ b/tests/test_site_r4_systems.py @@ -288,12 +288,13 @@ class ConsolesFieldNamesMachinesOnce(unittest.TestCase): consumers = _consumers({}) with gs.markup.using("mkdocs"): one = sum(len(line) + 1 for line in gs._system_file_card(big[0], consumers)) - # Sega splits by size; every Sony console has a page whatever its size. + # Sega splits by size. Every Sony console has a page whatever its size. pages = gs.system_pages("Sega", {"Saturn": big, "Pico": small}, consumers, budget=one * 12) self.assertIn("sega-saturn", pages) self.assertEqual(_consoles(pages["sega"][0]), ["Pico"]) self.assertEqual(_consoles(pages["sega-saturn"][0]), ["Saturn"]) + self.addCleanup(gs.reset_console_pages) sony = gs.system_pages("Sony", {"PlayStation": big, "PocketStation": small}, consumers, budget=one * 12) self.assertEqual(_consoles(sony["sony"][0]), [])