class TestUserAndSystemSettings(unittest.TestCase): def setUp(self): self.system = IDASettings(PLUGIN_1).system self.user = IDASettings(PLUGIN_1).user def test_system_fallback(self): """ QSettings instances with scope "user" automatically fall back to scope "system" if the key doesn't exist. """ try: with clearing(self.system): with clearing(self.user): self.system.set_value(KEY_1, VALUE_1) self.assertEqual(self.user.get_value(KEY_1), VALUE_1) except PermissionError: g_logger.warning("swallowing PermissionError during testing")
class TestSettingsPrecendence(unittest.TestCase): def setUp(self): self.system = IDASettings(PLUGIN_1).system self.user = IDASettings(PLUGIN_1).user self.directory = IDASettings(PLUGIN_1).directory self.idb = IDASettings(PLUGIN_1).idb self.mux = IDASettings(PLUGIN_1) def test_user_gt_system(self): try: with clearing(self.system): with clearing(self.user): self.system.set_value(KEY_1, VALUE_1) self.user.set_value(KEY_1, VALUE_2) self.assertEqual(self.mux.get_value(KEY_1), VALUE_2) except PermissionError: g_logger.warning("swallowing PermissionError during testing") def test_directory_gt_user(self): try: with clearing(self.user): with clearing(self.directory): self.user.set_value(KEY_1, VALUE_1) self.directory.set_value(KEY_1, VALUE_2) self.assertEqual(self.mux.get_value(KEY_1), VALUE_2) except PermissionError: g_logger.warning("swallowing PermissionError during testing") def test_idb_gt_directory(self): try: with clearing(self.directory): with clearing(self.idb): self.directory.set_value(KEY_1, VALUE_1) self.idb.set_value(KEY_1, VALUE_2) self.assertEqual(self.mux.get_value(KEY_1), VALUE_2) except PermissionError: g_logger.warning("swallowing PermissionError during testing")