Example #1
0
    def test_09(self):
        """
        Test Case 09:
        Read simple configuration from string.

        Test is passed if expected information is present within
        :py:class:`magrathea.utils.compat.CompConfigParser` object.
        """
        test_string = "[test]\nfoo = bar"
        obj = CompConfigParser()
        obj.read_string(test_string)
        self.assertTrue(obj.has_section('test'))
        self.assertTrue(obj.has_option('test', 'foo'))
        self.assertEqual(obj.get('test', 'foo'), 'bar')
Example #2
0
    def test_08(self):
        """
        Test Case 08:
        Read simple configuration from file.

        Test is passed if expected information is present within
        :py:class:`magrathea.utils.compat.CompConfigParser` object.
        """
        test_string = "[test]\nfoo = bar"
        fp, name = tempfile.mkstemp()
        os.write(fp, to_bytes(test_string))
        os.close(fp)
        obj = CompConfigParser()
        obj.read(name)
        os.unlink(name)
        self.assertTrue(obj.has_section('test'))
        self.assertTrue(obj.has_option('test', 'foo'))
        self.assertEqual(obj.get('test', 'foo'), 'bar')