Preserve installed MAME settings in isolated ordinary runs

This commit is contained in:
Александр Петров
2026-09-17 22:59:47 +03:00
parent 5dc7998324
commit 0ade3b4821
4 changed files with 76 additions and 12 deletions
+20
View File
@@ -60,5 +60,25 @@ class LauncherTests(unittest.TestCase):
self.assertEqual(keyboards, {':': '1', ':kbd:ms_naturl': '1'})
def test_existing_config_is_merged_not_replaced(self):
with tempfile.TemporaryDirectory() as directory:
path = Path(directory)/'sprinter.cfg'
path.write_text('\ufeff<?xml version="1.0"?>\n<mameconfig version="10">'
'<system name="sprinter"><input>'
'<keyboard tag=":" enabled="0" />'
'<port tag=":TURBO" type="OTHER" mask="1" defvalue="0" value="1" />'
'</input><video><target index="0" /></video>'
'</system></mameconfig>', encoding='utf-8')
write_keyboard_config(Path(directory))
root = ET.parse(path).getroot()
system = root.find('system')
self.assertEqual([item.tag for item in system.find('input')],
['keyboard', 'keyboard', 'port'])
keyboards = {item.attrib['tag']: item.attrib['enabled']
for item in system.findall('input/keyboard')}
self.assertEqual(keyboards, {':': '1', ':kbd:ms_naturl': '1'})
self.assertEqual(system.find('input/port').attrib['value'], '1')
self.assertIsNotNone(system.find('video/target'))
if __name__ == '__main__':
unittest.main()