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")
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)
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")
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)
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)
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)