make[1]: Entering directory '/<<PKGBUILDDIR>>'
dh_auto_test -- --test-pytest --test-args tests/core
I: pybuild base:305: cd /<<PKGBUILDDIR>>/.pybuild/cpython3_3.12_authlib/build; python3.12 -m pytest tests/core
============================= test session starts ==============================
platform linux -- Python 3.12.2, pytest-8.0.2, pluggy-1.4.0
rootdir: /<<PKGBUILDDIR>>
configfile: tox.ini
plugins: anyio-4.2.0, asyncio-0.20.3, django-4.5.2
asyncio: mode=Mode.AUTO
collected 101 items
tests/core/test_oauth2/test_rfc6749_misc.py ...... [ 5%]
tests/core/test_oauth2/test_rfc7523.py ........................ [ 29%]
tests/core/test_oauth2/test_rfc7591.py ...... [ 35%]
tests/core/test_oauth2/test_rfc7662.py ...... [ 41%]
tests/core/test_oauth2/test_rfc8414.py .......................... [ 67%]
tests/core/test_oidc/test_core.py .......... [ 77%]
tests/core/test_oidc/test_discovery.py ....................... [100%]
============================= 101 passed in 0.65s ==============================
I: pybuild base:305: cd /<<PKGBUILDDIR>>/.pybuild/cpython3_3.11_authlib/build; python3.11 -m pytest tests/core
============================= test session starts ==============================
platform linux -- Python 3.11.8, pytest-8.0.2, pluggy-1.4.0
rootdir: /<<PKGBUILDDIR>>
configfile: tox.ini
plugins: anyio-4.2.0, asyncio-0.20.3, django-4.5.2
asyncio: mode=Mode.AUTO
collected 101 items
tests/core/test_oauth2/test_rfc6749_misc.py ...... [ 5%]
tests/core/test_oauth2/test_rfc7523.py ........................ [ 29%]
tests/core/test_oauth2/test_rfc7591.py ...... [ 35%]
tests/core/test_oauth2/test_rfc7662.py ...... [ 41%]
tests/core/test_oauth2/test_rfc8414.py .......................... [ 67%]
tests/core/test_oidc/test_core.py .......... [ 77%]
tests/core/test_oidc/test_discovery.py ....................... [100%]
============================= 101 passed in 0.67s ==============================
DJANGO_SETTINGS_MODULE=tests.clients.test_django.settings \
dh_auto_test -- --test-pytest --test-args tests/clients
I: pybuild base:305: cd /<<PKGBUILDDIR>>/.pybuild/cpython3_3.12_authlib/build; python3.12 -m pytest tests/clients
============================= test session starts ==============================
platform linux -- Python 3.12.2, pytest-8.0.2, pluggy-1.4.0
django: settings: tests.clients.test_django.settings (from env)
rootdir: /<<PKGBUILDDIR>>
configfile: tox.ini
plugins: anyio-4.2.0, asyncio-0.20.3, django-4.5.2
asyncio: mode=Mode.AUTO
collected 167 items
tests/clients/test_django/test_oauth_client.py ............. [ 7%]
tests/clients/test_flask/test_oauth_client.py .................... [ 19%]
tests/clients/test_flask/test_user_mixin.py ..... [ 22%]
tests/clients/test_httpx/test_assertion_client.py .. [ 23%]
tests/clients/test_httpx/test_async_assertion_client.py F. [ 25%]
tests/clients/test_httpx/test_async_oauth1_client.py FFFFFFF [ 29%]
tests/clients/test_httpx/test_async_oauth2_client.py FFFFFFFF...FFFFFFF. [ 40%]
FFFFF. [ 44%]
tests/clients/test_httpx/test_oauth1_client.py ....... [ 48%]
tests/clients/test_httpx/test_oauth2_client.py ...................... [ 61%]
tests/clients/test_requests/test_assertion_session.py .. [ 62%]
tests/clients/test_requests/test_oauth1_session.py ................ [ 72%]
tests/clients/test_requests/test_oauth2_session.py ..................... [ 85%]
......... [ 90%]
tests/clients/test_starlette/test_oauth_client.py ...FF.FFFF.F [ 97%]
tests/clients/test_starlette/test_user_mixin.py F..F [100%]
=================================== FAILURES ===================================
______________________________ test_refresh_token ______________________________
@contextlib.contextmanager
def map_httpcore_exceptions() -> typing.Iterator[None]:
try:
yield
/usr/lib/python3/dist-packages/httpx/_transports/default.py:69:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3/dist-packages/httpx/_transports/default.py:373: in handle_async_request
resp = await self._pool.handle_async_request(req) /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:216: in handle_async_request
raise exc from None /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:196: in handle_async_request
response = await connection.handle_async_request( /usr/lib/python3/dist-packages/httpcore/_async/http_proxy.py:289: in handle_async_request
connect_response = await self._connection.handle_async_request( /usr/lib/python3/dist-packages/httpcore/_async/connection.py:99: in handle_async_request
raise exc /usr/lib/python3/dist-packages/httpcore/_async/connection.py:76: in handle_async_request
stream = await self._connect(request) /usr/lib/python3/dist-packages/httpcore/_async/connection.py:122: in _connect
stream = await self._network_backend.connect_tcp(**kwargs) /usr/lib/python3/dist-packages/httpcore/_backends/auto.py:30: in connect_tcp
return await self._backend.connect_tcp( /usr/lib/python3/dist-packages/httpcore/_backends/anyio.py:112: in connect_tcp
with map_exceptions(exc_map):
/usr/lib/python3.12/contextlib.py:158: in __exit__
self.gen.throw(value)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
map = {<class 'TimeoutError'>: <class 'httpcore.ConnectTimeout'>, <class 'OSError'>: <class 'httpcore.ConnectError'>, <class 'anyio.BrokenResourceError'>: <class 'httpcore.ConnectError'>}
@contextlib.contextmanager
def map_exceptions(map: ExceptionMapping) -> Iterator[None]:
try:
yield
except Exception as exc: # noqa: PIE786
for from_exc, to_exc in map.items():
if isinstance(exc, from_exc):
raise to_exc(exc) from excE httpcore.ConnectError: All connection attempts failed
/usr/lib/python3/dist-packages/httpcore/_exceptions.py:14: ConnectError
The above exception was the direct cause of the following exception:
@pytest.mark.asyncio
async def test_refresh_token():
async def verifier(request):
content = await request.body()
if str(request.url) == 'https://i.b/token':
assert b'assertion=' in content
async with AsyncAssertionClient(
'https://i.b/token',
grant_type=AsyncAssertionClient.JWT_BEARER_GRANT_TYPE,
issuer='foo',
subject='foo',
audience='foo',
alg='HS256',
key='secret',
app=AsyncMockDispatch(default_token, assert_func=verifier)
) as client:
await client.get('https://i.b')
tests/clients/test_httpx/test_async_assertion_client.py:33:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3/dist-packages/httpx/_client.py:1801: in get
return await self.request( authlib/integrations/httpx_client/assertion_client.py:38: in request
await self.refresh_token() authlib/integrations/httpx_client/assertion_client.py:45: in _refresh_token
resp = await self.request( authlib/integrations/httpx_client/assertion_client.py:41: in request
return await super().request( /usr/lib/python3/dist-packages/httpx/_client.py:1574: in request
return await self.send(request, auth=auth, follow_redirects=follow_redirects)
/usr/lib/python3/dist-packages/httpx/_client.py:1661: in send
response = await self._send_handling_auth( /usr/lib/python3/dist-packages/httpx/_client.py:1689: in _send_handling_auth
response = await self._send_handling_redirects( /usr/lib/python3/dist-packages/httpx/_client.py:1726: in _send_handling_redirects
response = await self._send_single_request(request) /usr/lib/python3/dist-packages/httpx/_client.py:1763: in _send_single_request
response = await transport.handle_async_request(request) /usr/lib/python3/dist-packages/httpx/_transports/default.py:372: in handle_async_request
with map_httpcore_exceptions():
/usr/lib/python3.12/contextlib.py:158: in __exit__
self.gen.throw(value)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
@contextlib.contextmanager
def map_httpcore_exceptions() -> typing.Iterator[None]:
try:
yield
except Exception as exc:
mapped_exc = None
for from_exc, to_exc in HTTPCORE_EXC_MAP.items():
if not isinstance(exc, from_exc):
continue
# We want to map to the most specific exception we can find.
# Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to
# `httpx.ReadTimeout`, not just `httpx.TimeoutException`.
if mapped_exc is None or issubclass(to_exc, mapped_exc):
mapped_exc = to_exc
if mapped_exc is None: # pragma: no cover
raise
message = str(exc)
raise mapped_exc(message) from excE httpx.ConnectError: All connection attempts failed
/usr/lib/python3/dist-packages/httpx/_transports/default.py:86: ConnectError _____________________ test_fetch_request_token_via_header ______________________
@contextlib.contextmanager
def map_httpcore_exceptions() -> typing.Iterator[None]:
try:
yield
/usr/lib/python3/dist-packages/httpx/_transports/default.py:69:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3/dist-packages/httpx/_transports/default.py:373: in handle_async_request
resp = await self._pool.handle_async_request(req) /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:216: in handle_async_request
raise exc from None /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:196: in handle_async_request
response = await connection.handle_async_request( /usr/lib/python3/dist-packages/httpcore/_async/http_proxy.py:289: in handle_async_request
connect_response = await self._connection.handle_async_request( /usr/lib/python3/dist-packages/httpcore/_async/connection.py:99: in handle_async_request
raise exc /usr/lib/python3/dist-packages/httpcore/_async/connection.py:76: in handle_async_request
stream = await self._connect(request) /usr/lib/python3/dist-packages/httpcore/_async/connection.py:122: in _connect
stream = await self._network_backend.connect_tcp(**kwargs) /usr/lib/python3/dist-packages/httpcore/_backends/auto.py:30: in connect_tcp
return await self._backend.connect_tcp( /usr/lib/python3/dist-packages/httpcore/_backends/anyio.py:112: in connect_tcp
with map_exceptions(exc_map):
/usr/lib/python3.12/contextlib.py:158: in __exit__
self.gen.throw(value)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
map = {<class 'TimeoutError'>: <class 'httpcore.ConnectTimeout'>, <class 'OSError'>: <class 'httpcore.ConnectError'>, <class 'anyio.BrokenResourceError'>: <class 'httpcore.ConnectError'>}
@contextlib.contextmanager
def map_exceptions(map: ExceptionMapping) -> Iterator[None]:
try:
yield
except Exception as exc: # noqa: PIE786
for from_exc, to_exc in map.items():
if isinstance(exc, from_exc):
raise to_exc(exc) from excE httpcore.ConnectError: All connection attempts failed
/usr/lib/python3/dist-packages/httpcore/_exceptions.py:14: ConnectError
The above exception was the direct cause of the following exception:
@pytest.mark.asyncio
async def test_fetch_request_token_via_header():
request_token = {'oauth_token': '1', 'oauth_token_secret': '2'}
async def assert_func(request):
auth_header = request.headers.get('authorization')
assert 'oauth_consumer_key="id"' in auth_header
assert 'oauth_signature=' in auth_header
app = AsyncMockDispatch(request_token, assert_func=assert_func)
async with AsyncOAuth1Client('id', 'secret', app=app) as client:
response = await client.fetch_request_token(oauth_url)
tests/clients/test_httpx/test_async_oauth1_client.py:24:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
authlib/integrations/httpx_client/oauth1_client.py:68: in _fetch_token
resp = await self.post(url, **kwargs) /usr/lib/python3/dist-packages/httpx/_client.py:1892: in post
return await self.request( /usr/lib/python3/dist-packages/httpx/_client.py:1574: in request
return await self.send(request, auth=auth, follow_redirects=follow_redirects)
/usr/lib/python3/dist-packages/httpx/_client.py:1661: in send
response = await self._send_handling_auth( /usr/lib/python3/dist-packages/httpx/_client.py:1689: in _send_handling_auth
response = await self._send_handling_redirects( /usr/lib/python3/dist-packages/httpx/_client.py:1726: in _send_handling_redirects
response = await self._send_single_request(request) /usr/lib/python3/dist-packages/httpx/_client.py:1763: in _send_single_request
response = await transport.handle_async_request(request) /usr/lib/python3/dist-packages/httpx/_transports/default.py:372: in handle_async_request
with map_httpcore_exceptions():
/usr/lib/python3.12/contextlib.py:158: in __exit__
self.gen.throw(value)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
@contextlib.contextmanager
def map_httpcore_exceptions() -> typing.Iterator[None]:
try:
yield
except Exception as exc:
mapped_exc = None
for from_exc, to_exc in HTTPCORE_EXC_MAP.items():
if not isinstance(exc, from_exc):
continue
# We want to map to the most specific exception we can find.
# Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to
# `httpx.ReadTimeout`, not just `httpx.TimeoutException`.
if mapped_exc is None or issubclass(to_exc, mapped_exc):
mapped_exc = to_exc
if mapped_exc is None: # pragma: no cover
raise
message = str(exc)
raise mapped_exc(message) from excE httpx.ConnectError: All connection attempts failed
/usr/lib/python3/dist-packages/httpx/_transports/default.py:86: ConnectError ______________________ test_fetch_request_token_via_body _______________________
@contextlib.contextmanager
def map_httpcore_exceptions() -> typing.Iterator[None]:
try:
yield
/usr/lib/python3/dist-packages/httpx/_transports/default.py:69:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3/dist-packages/httpx/_transports/default.py:373: in handle_async_request
resp = await self._pool.handle_async_request(req) /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:216: in handle_async_request
raise exc from None /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:196: in handle_async_request
response = await connection.handle_async_request( /usr/lib/python3/dist-packages/httpcore/_async/http_proxy.py:289: in handle_async_request
connect_response = await self._connection.handle_async_request( /usr/lib/python3/dist-packages/httpcore/_async/connection.py:99: in handle_async_request
raise exc /usr/lib/python3/dist-packages/httpcore/_async/connection.py:76: in handle_async_request
stream = await self._connect(request) /usr/lib/python3/dist-packages/httpcore/_async/connection.py:122: in _connect
stream = await self._network_backend.connect_tcp(**kwargs) /usr/lib/python3/dist-packages/httpcore/_backends/auto.py:30: in connect_tcp
return await self._backend.connect_tcp( /usr/lib/python3/dist-packages/httpcore/_backends/anyio.py:112: in connect_tcp
with map_exceptions(exc_map):
/usr/lib/python3.12/contextlib.py:158: in __exit__
self.gen.throw(value)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
map = {<class 'TimeoutError'>: <class 'httpcore.ConnectTimeout'>, <class 'OSError'>: <class 'httpcore.ConnectError'>, <class 'anyio.BrokenResourceError'>: <class 'httpcore.ConnectError'>}
@contextlib.contextmanager
def map_exceptions(map: ExceptionMapping) -> Iterator[None]:
try:
yield
except Exception as exc: # noqa: PIE786
for from_exc, to_exc in map.items():
if isinstance(exc, from_exc):
raise to_exc(exc) from excE httpcore.ConnectError: All connection attempts failed
/usr/lib/python3/dist-packages/httpcore/_exceptions.py:14: ConnectError
The above exception was the direct cause of the following exception:
@pytest.mark.asyncio
async def test_fetch_request_token_via_body():
request_token = {'oauth_token': '1', 'oauth_token_secret': '2'}
async def assert_func(request):
auth_header = request.headers.get('authorization')
assert auth_header is None
content = await request.body()
assert b'oauth_consumer_key=id' in content
assert b'&oauth_signature=' in content
mock_response = AsyncMockDispatch(request_token, assert_func=assert_func)
async with AsyncOAuth1Client(
'id', 'secret', signature_type=SIGNATURE_TYPE_BODY,
app=mock_response,
) as client:
response = await client.fetch_request_token(oauth_url)
tests/clients/test_httpx/test_async_oauth1_client.py:47:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
authlib/integrations/httpx_client/oauth1_client.py:68: in _fetch_token
resp = await self.post(url, **kwargs) /usr/lib/python3/dist-packages/httpx/_client.py:1892: in post
return await self.request( /usr/lib/python3/dist-packages/httpx/_client.py:1574: in request
return await self.send(request, auth=auth, follow_redirects=follow_redirects)
/usr/lib/python3/dist-packages/httpx/_client.py:1661: in send
response = await self._send_handling_auth( /usr/lib/python3/dist-packages/httpx/_client.py:1689: in _send_handling_auth
response = await self._send_handling_redirects( /usr/lib/python3/dist-packages/httpx/_client.py:1726: in _send_handling_redirects
response = await self._send_single_request(request) /usr/lib/python3/dist-packages/httpx/_client.py:1763: in _send_single_request
response = await transport.handle_async_request(request) /usr/lib/python3/dist-packages/httpx/_transports/default.py:372: in handle_async_request
with map_httpcore_exceptions():
/usr/lib/python3.12/contextlib.py:158: in __exit__
self.gen.throw(value)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
@contextlib.contextmanager
def map_httpcore_exceptions() -> typing.Iterator[None]:
try:
yield
except Exception as exc:
mapped_exc = None
for from_exc, to_exc in HTTPCORE_EXC_MAP.items():
if not isinstance(exc, from_exc):
continue
# We want to map to the most specific exception we can find.
# Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to
# `httpx.ReadTimeout`, not just `httpx.TimeoutException`.
if mapped_exc is None or issubclass(to_exc, mapped_exc):
mapped_exc = to_exc
if mapped_exc is None: # pragma: no cover
raise
message = str(exc)
raise mapped_exc(message) from excE httpx.ConnectError: All connection attempts failed
/usr/lib/python3/dist-packages/httpx/_transports/default.py:86: ConnectError ______________________ test_fetch_request_token_via_query ______________________
@contextlib.contextmanager
def map_httpcore_exceptions() -> typing.Iterator[None]:
try:
yield
/usr/lib/python3/dist-packages/httpx/_transports/default.py:69:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3/dist-packages/httpx/_transports/default.py:373: in handle_async_request
resp = await self._pool.handle_async_request(req) /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:216: in handle_async_request
raise exc from None /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:196: in handle_async_request
response = await connection.handle_async_request( /usr/lib/python3/dist-packages/httpcore/_async/http_proxy.py:289: in handle_async_request
connect_response = await self._connection.handle_async_request( /usr/lib/python3/dist-packages/httpcore/_async/connection.py:99: in handle_async_request
raise exc /usr/lib/python3/dist-packages/httpcore/_async/connection.py:76: in handle_async_request
stream = await self._connect(request) /usr/lib/python3/dist-packages/httpcore/_async/connection.py:122: in _connect
stream = await self._network_backend.connect_tcp(**kwargs) /usr/lib/python3/dist-packages/httpcore/_backends/auto.py:30: in connect_tcp
return await self._backend.connect_tcp( /usr/lib/python3/dist-packages/httpcore/_backends/anyio.py:112: in connect_tcp
with map_exceptions(exc_map):
/usr/lib/python3.12/contextlib.py:158: in __exit__
self.gen.throw(value)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
map = {<class 'TimeoutError'>: <class 'httpcore.ConnectTimeout'>, <class 'OSError'>: <class 'httpcore.ConnectError'>, <class 'anyio.BrokenResourceError'>: <class 'httpcore.ConnectError'>}
@contextlib.contextmanager
def map_exceptions(map: ExceptionMapping) -> Iterator[None]:
try:
yield
except Exception as exc: # noqa: PIE786
for from_exc, to_exc in map.items():
if isinstance(exc, from_exc):
raise to_exc(exc) from excE httpcore.ConnectError: All connection attempts failed
/usr/lib/python3/dist-packages/httpcore/_exceptions.py:14: ConnectError
The above exception was the direct cause of the following exception:
@pytest.mark.asyncio
async def test_fetch_request_token_via_query():
request_token = {'oauth_token': '1', 'oauth_token_secret': '2'}
async def assert_func(request):
auth_header = request.headers.get('authorization')
assert auth_header is None
url = str(request.url)
assert 'oauth_consumer_key=id' in url
assert '&oauth_signature=' in url
mock_response = AsyncMockDispatch(request_token, assert_func=assert_func)
async with AsyncOAuth1Client(
'id', 'secret', signature_type=SIGNATURE_TYPE_QUERY,
app=mock_response,
) as client:
response = await client.fetch_request_token(oauth_url)
tests/clients/test_httpx/test_async_oauth1_client.py:70:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
authlib/integrations/httpx_client/oauth1_client.py:68: in _fetch_token
resp = await self.post(url, **kwargs) /usr/lib/python3/dist-packages/httpx/_client.py:1892: in post
return await self.request( /usr/lib/python3/dist-packages/httpx/_client.py:1574: in request
return await self.send(request, auth=auth, follow_redirects=follow_redirects)
/usr/lib/python3/dist-packages/httpx/_client.py:1661: in send
response = await self._send_handling_auth( /usr/lib/python3/dist-packages/httpx/_client.py:1689: in _send_handling_auth
response = await self._send_handling_redirects( /usr/lib/python3/dist-packages/httpx/_client.py:1726: in _send_handling_redirects
response = await self._send_single_request(request) /usr/lib/python3/dist-packages/httpx/_client.py:1763: in _send_single_request
response = await transport.handle_async_request(request) /usr/lib/python3/dist-packages/httpx/_transports/default.py:372: in handle_async_request
with map_httpcore_exceptions():
/usr/lib/python3.12/contextlib.py:158: in __exit__
self.gen.throw(value)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
@contextlib.contextmanager
def map_httpcore_exceptions() -> typing.Iterator[None]:
try:
yield
except Exception as exc:
mapped_exc = None
for from_exc, to_exc in HTTPCORE_EXC_MAP.items():
if not isinstance(exc, from_exc):
continue
# We want to map to the most specific exception we can find.
# Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to
# `httpx.ReadTimeout`, not just `httpx.TimeoutException`.
if mapped_exc is None or issubclass(to_exc, mapped_exc):
mapped_exc = to_exc
if mapped_exc is None: # pragma: no cover
raise
message = str(exc)
raise mapped_exc(message) from excE httpx.ConnectError: All connection attempts failed
/usr/lib/python3/dist-packages/httpx/_transports/default.py:86: ConnectError ___________________________ test_fetch_access_token ____________________________
@contextlib.contextmanager
def map_httpcore_exceptions() -> typing.Iterator[None]:
try:
yield
/usr/lib/python3/dist-packages/httpx/_transports/default.py:69:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3/dist-packages/httpx/_transports/default.py:373: in handle_async_request
resp = await self._pool.handle_async_request(req) /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:216: in handle_async_request
raise exc from None /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:196: in handle_async_request
response = await connection.handle_async_request( /usr/lib/python3/dist-packages/httpcore/_async/http_proxy.py:289: in handle_async_request
connect_response = await self._connection.handle_async_request( /usr/lib/python3/dist-packages/httpcore/_async/connection.py:99: in handle_async_request
raise exc /usr/lib/python3/dist-packages/httpcore/_async/connection.py:76: in handle_async_request
stream = await self._connect(request) /usr/lib/python3/dist-packages/httpcore/_async/connection.py:122: in _connect
stream = await self._network_backend.connect_tcp(**kwargs) /usr/lib/python3/dist-packages/httpcore/_backends/auto.py:30: in connect_tcp
return await self._backend.connect_tcp( /usr/lib/python3/dist-packages/httpcore/_backends/anyio.py:112: in connect_tcp
with map_exceptions(exc_map):
/usr/lib/python3.12/contextlib.py:158: in __exit__
self.gen.throw(value)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
map = {<class 'TimeoutError'>: <class 'httpcore.ConnectTimeout'>, <class 'OSError'>: <class 'httpcore.ConnectError'>, <class 'anyio.BrokenResourceError'>: <class 'httpcore.ConnectError'>}
@contextlib.contextmanager
def map_exceptions(map: ExceptionMapping) -> Iterator[None]:
try:
yield
except Exception as exc: # noqa: PIE786
for from_exc, to_exc in map.items():
if isinstance(exc, from_exc):
raise to_exc(exc) from excE httpcore.ConnectError: All connection attempts failed
/usr/lib/python3/dist-packages/httpcore/_exceptions.py:14: ConnectError
The above exception was the direct cause of the following exception:
@pytest.mark.asyncio
async def test_fetch_access_token():
request_token = {'oauth_token': '1', 'oauth_token_secret': '2'}
async def assert_func(request):
auth_header = request.headers.get('authorization')
assert 'oauth_verifier="d"' in auth_header
assert 'oauth_token="foo"' in auth_header
assert 'oauth_consumer_key="id"' in auth_header
assert 'oauth_signature=' in auth_header
mock_response = AsyncMockDispatch(request_token, assert_func=assert_func)
async with AsyncOAuth1Client(
'id', 'secret', token='foo', token_secret='bar',
app=mock_response,
) as client:
with pytest.raises(OAuthError):
await client.fetch_access_token(oauth_url)
response = await client.fetch_access_token(oauth_url, verifier='d')
tests/clients/test_httpx/test_async_oauth1_client.py:94:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
authlib/integrations/httpx_client/oauth1_client.py:63: in fetch_access_token
token = await self._fetch_token(url, **kwargs) authlib/integrations/httpx_client/oauth1_client.py:68: in _fetch_token
resp = await self.post(url, **kwargs) /usr/lib/python3/dist-packages/httpx/_client.py:1892: in post
return await self.request( /usr/lib/python3/dist-packages/httpx/_client.py:1574: in request
return await self.send(request, auth=auth, follow_redirects=follow_redirects)
/usr/lib/python3/dist-packages/httpx/_client.py:1661: in send
response = await self._send_handling_auth( /usr/lib/python3/dist-packages/httpx/_client.py:1689: in _send_handling_auth
response = await self._send_handling_redirects( /usr/lib/python3/dist-packages/httpx/_client.py:1726: in _send_handling_redirects
response = await self._send_single_request(request) /usr/lib/python3/dist-packages/httpx/_client.py:1763: in _send_single_request
response = await transport.handle_async_request(request) /usr/lib/python3/dist-packages/httpx/_transports/default.py:372: in handle_async_request
with map_httpcore_exceptions():
/usr/lib/python3.12/contextlib.py:158: in __exit__
self.gen.throw(value)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
@contextlib.contextmanager
def map_httpcore_exceptions() -> typing.Iterator[None]:
try:
yield
except Exception as exc:
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 300 |
Nodes: | 16 (2 / 14) |
Uptime: | 07:20:36 |
Calls: | 6,706 |
Files: | 12,236 |
Messages: | 5,350,636 |