def test_get_default_client_with_non_callable(): # Setup old_default = register.get_default_client() register.set_default_client("client") default_client = register.get_default_client() register.set_default_client(old_default) # Verify: an object that is not callable should be returned as set. assert default_client == "client"
@register.handler def _client_class_handler(key): if inspect.isclass(key) and issubclass(key, interfaces.HttpClientAdapter): return key() try: from uplink.clients.aiohttp_ import AiohttpClient except (ImportError, SyntaxError) as error: # pragma: no cover from uplink.clients import interfaces class AiohttpClient(interfaces.HttpClientAdapter): def __init__(self, *args, **kwargs): raise NotImplementedError( "Failed to load `aiohttp` client: you may be using a version " "of Python below 3.3. `aiohttp` requires Python 3.4+.") def create_request(self): pass __all__ = [ "RequestsClient", "AiohttpClient", "TwistedClient", ] register.set_default_client(RequestsClient)