def test_resolve_fail(self, mock_path): mock_path.isfile.return_value = False with self.assertRaises(RuntimeError): Config.resolve()
def _read_file(name, encoding='utf-8'): """ Read the contents of a file. :param name: The name of the file in the current directory. :param encoding: The encoding of the file; defaults to utf-8. :return: The contents of the file. """ with codecs.open(name, encoding=encoding) as f: return f.read() __version__ = _read_file(path.join(path.dirname(__file__), 'VERSION')).strip() _config = Config.resolve() def host(identifier): """ Retrieve information about a host. :param identifier: The host's name, key or hash. :return: The matching host. """ identity = _config.find_host(identifier) return Host.request_from_identity(identity) def hosts(): """