def test_settings_fs_save(self): path = os.path.join(self.dir, 'settings.cfg') fs = FileStorage(path) self.assertEqual(fs.load(), {'here': ''}) fs.save({'group.node1': 'value'}) self.assertEqual(fs.load(), {'group.node1': 'value', 'here': ''}) self.assertEqual(open(path).read(), '[DEFAULT]\ngroup.node1 = value\n\n')
def test_settings_fs_save_to_existing(self): path = os.path.join(self.dir, 'settings.cfg') f = open(path, 'wb') f.write('[TEST]\ngroup.node1 = value\n\n') f.close() fs = FileStorage(path) self.assertEqual(fs.load(), {'here': ''}) fs.save({'group.node1': 'value'}) self.assertEqual(fs.load(), {'group.node1': 'value', 'here': ''}) self.assertEqual( open(path).read(), '[DEFAULT]\ngroup.node1 = value\n\n[TEST]\ngroup.node1 = value\n\n')
def test_settings_fs_save_nosettings_file(self): fs = FileStorage(None) self.assertEqual(fs.save({'group.node1': 'test'}), None)