def test_find_config_files_one(self): error_message = "The file '{0}' should have been loaded by the "\ "dodai.util.find.config_files function." files = find.config_files(self._fixture.PROJECT, self._fixture.custom_filenames) for name in files: msg = error_message.format(name) self.assertTrue(name.name in self._fixture.good_filenames, msg=msg)
def test_find_config_files_three(self): error_message = "The file '{0}' should NOT have been loaded by the "\ "dodai.util.find.conf_files function" files = find.config_files(self._fixture.PROJECT, self._fixture.custom_filenames) loaded_files = [] for name in files: loaded_files.append(name.name) for name in self._fixture.bogus_filenames: msg = error_message.format(name) self.assertFalse(name in loaded_files, msg=msg)
def test_find_config_files(): """Test to make sure that the config files are being found """ path_base = "~/test__dodai__config.test" path = os.path.expanduser(path_base) if os.path.exists(path): os.remove(path) f = open(path, 'w') f.close() files = find.config_files('test__dodai_config', path) nt.ok_(len(files) > 0) nt.eq_(files[0][0], path) if os.path.exists(path): os.remove(path)
def test_find_multiple_config_files(): """Test to make sure that the multiple config files are being found """ config_files = ['~/test__dodai__config.test', '~/test__dodai__config.cfg'] non_exist_file = '~/test__dodai_config' good_files = [] # touch the files for config_file in config_files: path = os.path.expanduser(config_file) good_files.append(path) if os.path.exists(path): os.remove(path) f = open(path, 'w') f.close() # Add a non existing file filenames = config_files + [non_exist_file] non_exist_file = os.path.exists(non_exist_file) files = find.config_files('test__dodai__config_', filenames, 'utf-8') for filename in good_files: nt.ok_((filename, 'utf-8') in files) nt.ok_((non_exist_file, 'utf-8') not in files) for filename in good_files: os.remove(filename)
def _config_files(self, config_files): if config_files: return find.config_files(self.project, config_files) else: return find.config_files(self.project)
def test_find_default_config_files(self): files = find.config_files(self.project_name) for filename, encoding in files: nt.ok_((filename, encoding) in files, msg=self.MESSAGE.format( filename=filename, encoding=encoding))