Merge pull request #3516 from rommapp/copilot/bug-fix-assign-system-folder

Fix config.yml serialization breaking folder-to-platform mappings
This commit is contained in:
Georges-Antoine Assi
2026-06-13 16:16:36 -04:00
committed by GitHub
3 changed files with 42 additions and 2 deletions

View File

@@ -782,8 +782,8 @@ class ConfigManager:
"gamelist": {
"export": self.config.GAMELIST_AUTO_EXPORT_ON_SCAN,
"media": {
"thumbnail": self.config.GAMELIST_MEDIA_THUMBNAIL,
"image": self.config.GAMELIST_MEDIA_IMAGE,
"thumbnail": str(self.config.GAMELIST_MEDIA_THUMBNAIL),
"image": str(self.config.GAMELIST_MEDIA_IMAGE),
},
},
"pegasus": {

View File

@@ -0,0 +1,19 @@
import pytest
from config.config_manager import ConfigManager
from config.config_manager import config_manager as cm
@pytest.fixture(autouse=True)
def restore_config_manager_singleton():
"""``ConfigManager`` is a process-wide singleton (``__new__`` returns the
shared instance). Tests in this module point it at temporary config files
and mutate it (e.g. ``add_platform_binding``), which would otherwise leak
that state into other test modules through the global ``config_manager``.
Re-initialize the singleton from its original config file after each test
so the global instance returns to its default state.
"""
original_config_file = cm.config_file
yield
ConfigManager(original_config_file)

View File

@@ -160,3 +160,24 @@ def test_malformed_yaml_falls_back_to_defaults():
assert loader.config.ROMS_FOLDER_NAME == "roms"
assert loader.config.FIRMWARE_FOLDER_NAME == "bios"
assert loader.config.SCAN_MEDIA == ["box2d", "screenshot", "manual"]
def test_config_updates_serialize_gamelist_media_as_plain_strings(tmp_path):
config_file = tmp_path / "config.yml"
config_file.write_text(
"scan:\n"
" gamelist:\n"
" media:\n"
" thumbnail: box2d\n"
" image: screenshot\n"
)
loader = ConfigManager(str(config_file))
loader.add_platform_binding("atarist", "atari-st")
config_text = config_file.read_text()
assert "!!python/object" not in config_text
assert "thumbnail: box2d" in config_text
assert "image: screenshot" in config_text
reloaded = ConfigManager(str(config_file))
assert reloaded.config.PLATFORMS_BINDING == {"atarist": "atari-st"}