示例#1
0
    def test_config(self):
        c = Configuration()
        c.read(self._config_path())

        # option doesn't exits
        self.assertTrue(not c.has_option("section", "optionxxx"))

        # option exits
        self.assertTrue(c.has_option("section", "option"))

        # section doesn't exits
        self.assertTrue(not c.has_section("sectionxxx"))

        # section exits
        self.assertTrue(c.has_section("section"))

        # option doesn't exits
        def t():
            c.get("section", "optionxxx")

        self.assertRaises(ConfigParser.NoOptionError, t)

        # section doesn't exits
        def t():
            c.get("sectionxxx", "option")

        self.assertRaises(ConfigParser.NoSectionError, t)

        # fetch value
        self.assertEqual(c.get("section", "option"), "value")
示例#2
0
    def test_config(self):
        c = Configuration()
        c.read(self._config_path())

        # option doesn't exits
        self.assertTrue(not c.has_option("section", "optionxxx"))

        # option exits
        self.assertTrue(c.has_option("section", "option"))

        # section doesn't exits
        self.assertTrue(not c.has_section("sectionxxx"))

        # section exits
        self.assertTrue(c.has_section("section"))

        # option doesn't exits
        def t():
            c.get("section", "optionxxx")

        self.assertRaises(ConfigParser.NoOptionError, t)

        # section doesn't exits
        def t():
            c.get("sectionxxx", "option")

        self.assertRaises(ConfigParser.NoSectionError, t)

        # fetch value
        self.assertEqual(c.get("section", "option"), "value")