mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-19 12:59:58 -04:00
Read launcher.json saved with a BOM, and keep a copy of one that is not valid JSON.
The docs ask players to edit the file by hand (github_token, feed_repo). A BOM, which an editor may add, made the file unreadable and every setting, the game folder included, fell back to its default, so the launcher showed the first run again; a typo did the same and the next save overwrote what the player wrote. The file is now read with utf-8-sig, and a file that is still no JSON is copied to launcher.json.bad and named in the log. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -268,6 +268,20 @@ class SettingsTest(Tmp):
|
||||
self.assertEqual((s['auto_check'], s['channel']), (True, 'preview'))
|
||||
self.assertNotIn('junk', s)
|
||||
|
||||
def test_bom_and_typo(self):
|
||||
# a file saved by an editor with a BOM reads as written; one with a typo keeps a copy before a save replaces it
|
||||
self.layout.settings.write_bytes(b'\xef\xbb\xbf' + json.dumps({'game_dir': 'D:/g'}).encode())
|
||||
s = settings.Settings(self.layout.settings)
|
||||
self.assertEqual(s['game_dir'], 'D:/g')
|
||||
self.assertFalse(s.unreadable)
|
||||
typo = '{"game_dir": "D:/g", "github_token": "t",}'
|
||||
self.layout.settings.write_text(typo, encoding='utf-8')
|
||||
s = settings.Settings(self.layout.settings)
|
||||
self.assertTrue(s.unreadable)
|
||||
self.assertEqual(s['game_dir'], '')
|
||||
s.save()
|
||||
self.assertEqual(self.layout.settings.with_name('launcher.json.bad').read_text(encoding='utf-8'), typo)
|
||||
|
||||
|
||||
class UninstallTest(Tmp):
|
||||
def tree(self, root, rels):
|
||||
|
||||
Reference in New Issue
Block a user