def test_lists(self): self.assertEqual(os.path.exists(self.filepath), False) os.environ["CALVIN_CONFIG_PATH"] = self.filepath _conf = CalConfig() _conf.add_section("test") test_item = [str(x) for x in range(10)] _conf.set("test", "BANAN2", test_item) self.assertEqual(_conf.get("test", "BANAN2"), test_item)
def test_env_override(self): self.assertEqual(os.path.exists(self.filepath), False) os.environ["CALVIN_CONFIG_PATH"] = self.filepath _conf = CalConfig() _conf.add_section("test") for a in range(10): _conf.set("test", "APA%d" % a, "%d" % a) os.environ["CALVIN_APA%d" % a] = "100" self.assertEqual(_conf.get("test", "APA%d" % a), 100)
def test_set_get(self): self.assertEqual(os.path.exists(self.filepath), False) print os.environ os.environ["CALVIN_CONFIG_PATH"] = self.filepath _conf = CalConfig() _conf.add_section("test") for a in range(10): _conf.set("test", "BANAN%d" % a, str(a)) self.assertEqual(_conf.get("test", "BANAN%d" % a), str(a)) for a in range(10): _conf.set("test", "BANAN%d" % a, a) self.assertEqual(_conf.get("test", "BANAN%d" % a), a) for a in range(10): _conf.set("test", "BANAN%d" % a, range(10)) self.assertEqual(_conf.get("test", "BANAN%d" % a), range(10)) # Should this two become the same ? for a in range(10): _conf.set("test", "BANAN%d" % a, dict(zip(range(10), range(10)))) self.assertEqual(_conf.get("test", "BANAN%d" % a), dict(zip([str(x) for x in range(10)], range(10)))) for a in range(10): _conf.set("test", "BANAN%d" % a, dict(zip([str(x) for x in range(10)], range(10)))) self.assertEqual(_conf.get("test", "BANAN%d" % a), dict(zip([str(x) for x in range(10)], range(10)))) for a in range(10): _conf.set("test", "BANAN%d" % a, dict(zip([str(x) for x in range(10)], [range(10)]))) self.assertEqual(_conf.get("test", "BANAN%d" % a), dict(zip([str(x) for x in range(10)], [range(10)])))
def test_env_override_list_append(self): self.assertEqual(os.path.exists(self.filepath), False) os.environ["CALVIN_CONFIG_PATH"] = self.filepath _conf = CalConfig() _conf.add_section("test") test_item = [str(x) for x in range(10)] _conf.set("test", "KAKA", test_item) os.environ["CALVIN_KAKA"] = "HEJ" self.assertEqual(_conf.get("test", "KAKA"), "HEJ") test_item = range(10) test_item2 = ["HEJ", "hej", "HEJ"] _conf.set("test", "KAKA", test_item) os.environ["CALVIN_KAKA"] = os.pathsep.join(test_item2) self.assertEqual(_conf.get("test", "KAKA"), test_item2 + test_item) test_item = [str(x) for x in range(10)] _conf.set("test", "KAKA", test_item) os.environ["CALVIN_KAKA"] = '["HEJ", "hej", "HEJ"]' self.assertEqual(_conf.get("test", "KAKA"), test_item2 + test_item)