Example #1
0
    def test_attribute(self):
        """It should be able to access the attributes of the group"""
        config = os.path.join(self.data_path, "first_conf.cfg")
        data = read(config)
        group = data[0]

        self.assertEqual(group.input, "/etc/")
        self.assertEqual(group.language, "en")
Example #2
0
    def test_single_file(self):
        """
        It should be possible to load a single file by providing the path as
        a string.
        """
        config = os.path.join(self.data_path, "first_conf.cfg")
        data = read(config)

        self.assertEqual(len(data), 1)
Example #3
0
    def test_invalid_attribute(self):
        """
        The group should raise AttributeError when accessing invalid
        attributes
        """
        config = os.path.join(self.data_path, "first_conf.cfg")
        data = read(config)
        group = data[0]

        self.assertRaises(AttributeError, group.__getattr__, "foo")
        self.assertRaises(AttributeError, group.__getattr__, "bar")
Example #4
0
    def test_multiple_files(self):
        """
        It should be possible to load several files by providing a iterable
        containing the paths.
        """

        config1 = os.path.join(self.data_path, "first_conf.cfg")
        config2 = os.path.join(self.data_path, "second_conf.cfg")
        data = read([config1, config2])

        self.assertEqual(len(data), 2)
Example #5
0
 def test_relative_path(self):
     """It should be possible to load files with a relative path"""
     with WorkingDir(self.path):
         data = read("./data/first_conf.cfg")
         self.assertEqual(len(data), 1)
Example #6
0
    def test_invalid_files(self):
        """Files that could not be found should be ignored when reading"""
        config = os.path.join(self.data_path, "first_conf.cfg")
        data = read([config, os.path.expanduser("~/conf.cfg")])

        self.assertEqual(len(data), 1)