def test_contains(self): empty_parser = ConfigParser({}) empty_parser.parse() parser = ConfigParser({"value": 1, "entry": "string content"}) parser.parse() with self.subTest("Testing empty parser"): self.assertFalse("something" in empty_parser) with self.subTest("Testing with keys"): self.assertTrue("value" in parser) self.assertFalse("value1" in parser) self.assertTrue("entry" in parser) self.assertFalse("entr" in parser)
def test_allow_missing_reference(self, config): default = ReferenceResolver.allow_missing_reference ReferenceResolver.allow_missing_reference = True parser = ConfigParser(config=config) for id in config: item = parser.get_parsed_content(id=id) if id in ("A", "B"): self.assertEqual(item, 1) elif id == "C": self.assertEqual(item, "@D") elif id == "E": self.assertEqual(item, "test@F") # restore the default value ReferenceResolver.allow_missing_reference = default with self.assertRaises(ValueError): parser.parse() parser.get_parsed_content(id="E")