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.
This commit is contained in:
Abdessamad Derraz committed 2026-11-04 04:47:01 +01:00
1 parent 36788a3cac
commit 1077d77125
3 files changed
+8 -2

No files matched your search

+3
View File
@@ -165,6 +165,9 @@ class TheSummaryLineIsProse(unittest.TestCase):
class TheIndexNamesEmulatorsAndSystems(unittest.TestCase): class TheIndexNamesEmulatorsAndSystems(unittest.TestCase):
def test_columns_and_counts(self): 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) saved = dict(siterender._system_page_map)
self.addCleanup(siterender.set_system_page_map, saved) self.addCleanup(siterender.set_system_page_map, saved)
siterender.set_system_page_map({"sony-playstation": ("sony", "PlayStation")}) siterender.set_system_page_map({"sony-playstation": ("sony", "PlayStation")})
+3 -1
View File
@@ -128,7 +128,7 @@ class TheConsoleBiosComesFirst(unittest.TestCase):
self.assertEqual(gs._start_with([_file("a.bin", "a")], _consumers({})), []) self.assertEqual(gs._start_with([_file("a.bin", "a")], _consumers({})), [])
def test_the_page_carries_the_line_under_the_console(self): 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()) page = gs.generate_system_page("Sega", {"Saturn": self.files}, self.required_only())
heading = page.index("## Saturn") heading = page.index("## Saturn")
self.assertLess(heading, page.index("**Start with**")) self.assertLess(heading, page.index("**Start with**"))
@@ -254,6 +254,8 @@ class TheSystemsIndexListsConsoles(unittest.TestCase):
be known to be under Sony.""" be known to be under Sony."""
def test_one_row_per_console_by_its_name(self): def test_one_row_per_console_by_its_name(self):
gs.reset_console_pages()
self.addCleanup(gs.reset_console_pages)
groups = { groups = {
"Sony": {"PlayStation": [_file("a.bin", "a")], "PlayStation 2": [_file("b.bin", "b")]}, "Sony": {"PlayStation": [_file("a.bin", "a")], "PlayStation 2": [_file("b.bin", "b")]},
"Other": {"ScummVM": [_file("c.bin", "c")]}, "Other": {"ScummVM": [_file("c.bin", "c")]},
+2 -1
View File
@@ -288,12 +288,13 @@ class ConsolesFieldNamesMachinesOnce(unittest.TestCase):
consumers = _consumers({}) consumers = _consumers({})
with gs.markup.using("mkdocs"): with gs.markup.using("mkdocs"):
one = sum(len(line) + 1 for line in gs._system_file_card(big[0], consumers)) 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}, pages = gs.system_pages("Sega", {"Saturn": big, "Pico": small},
consumers, budget=one * 12) consumers, budget=one * 12)
self.assertIn("sega-saturn", pages) self.assertIn("sega-saturn", pages)
self.assertEqual(_consoles(pages["sega"][0]), ["Pico"]) self.assertEqual(_consoles(pages["sega"][0]), ["Pico"])
self.assertEqual(_consoles(pages["sega-saturn"][0]), ["Saturn"]) self.assertEqual(_consoles(pages["sega-saturn"][0]), ["Saturn"])
self.addCleanup(gs.reset_console_pages)
sony = gs.system_pages("Sony", {"PlayStation": big, "PocketStation": small}, sony = gs.system_pages("Sony", {"PlayStation": big, "PocketStation": small},
consumers, budget=one * 12) consumers, budget=one * 12)
self.assertEqual(_consoles(sony["sony"][0]), []) self.assertEqual(_consoles(sony["sony"][0]), [])