def test_returns_false_if_load_fails_windows(self): file_path = self.tempdir.write(fake.config_file(), b'') config = ConfigReader(file_path, case_sensitive=True) config.set('states', '35', section='country') config.set('counties', 'None', section='country') environment = os.environ.copy() user = '******' environment['USER'] = user environment['COUNTER'] = 'never' config.to_env(environment) config.load_env(environment) items = config.get_items('main') with self.subTest(0): self.assertEqual(items['APPDATA'], os.environ['APPDATA']) with self.subTest(1): self.assertEqual(items['USER'], user) with self.subTest(2): self.assertEqual(items['ALLUSERSPROFILE'], os.environ['ALLUSERSPROFILE']) with self.subTest(3): self.assertRaises(KeyError, lambda: items['home']) with self.subTest(4): self.assertEqual(items['COUNTER'], 'never')
def test_returns_false_if_section_prepend_failed(self): file_path_1 = self._get_config_file() file_path_2 = self._get_config_file() f = open(file_path_1, 'w+') config = ConfigReader(file_path_2, f) config.set('country', 'Kenya') config.set('continent', 'Africa') config.set('state', 'None') config.set('count', '0', section='first') config.to_env() f.close() with self.subTest(0): self.assertEqual(os.environ.get('MAIN_COUNTRY'), 'Kenya') with self.subTest(1): self.assertEqual(os.environ.get('MAIN_CONTINENT'), 'Africa') with self.subTest(2): self.assertEqual(os.environ.get('MAIN_STATE'), 'None') with self.subTest(3): self.assertEqual(os.environ.get('FIRST_COUNT'), '0')