Replies: 1 comment
-
|
However with that patch pytest is failing in some units: + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-httpx-0.22.0-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-httpx-0.22.0-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -p no:randomly
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.12, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
rootdir: /home/tkloczko/rpmbuild/BUILD/httpx-0.22.0, configfile: pytest.ini
plugins: anyio-3.3.4, asyncio-0.18.2, trio-0.7.0
asyncio: mode=auto
collected 676 items
tests/test_api.py ........... [ 1%]
tests/test_asgi.py .................... [ 4%]
tests/test_auth.py ... [ 5%]
tests/test_config.py ............................... [ 9%]
tests/test_content.py ..................... [ 12%]
tests/test_decoders.py .....................F........ [ 17%]
tests/test_exceptions.py .... [ 17%]
tests/test_exported_members.py . [ 17%]
tests/test_main.py FFFFFFFFFF [ 19%]
tests/test_multipart.py .......................... [ 23%]
tests/test_status_codes.py ...... [ 24%]
tests/test_timeouts.py ........ [ 25%]
tests/test_utils.py ................................................ [ 32%]
tests/test_wsgi.py ........... [ 34%]
tests/client/test_async_client.py .................................................. [ 41%]
tests/client/test_auth.py ........................................... [ 47%]
tests/client/test_client.py ................................. [ 52%]
tests/client/test_cookies.py ....... [ 53%]
tests/client/test_event_hooks.py ......... [ 55%]
tests/client/test_headers.py ........... [ 56%]
tests/client/test_properties.py ....... [ 57%]
tests/client/test_proxies.py .....F.........................FF......................................... [ 68%]
tests/client/test_queryparams.py ... [ 69%]
tests/client/test_redirects.py ............................. [ 73%]
tests/models/test_cookies.py ....... [ 74%]
tests/models/test_headers.py .................. [ 77%]
tests/models/test_queryparams.py ............. [ 78%]
tests/models/test_requests.py ..................... [ 82%]
tests/models/test_responses.py ............F....................................................................... [ 94%]
tests/models/test_url.py ..................................... [100%]
================================================================================= FAILURES =================================================================================
___________________________________________________________________ test_text_decoder[data3-iso-8859-1] ____________________________________________________________________
data = (b'Accented: \xd6sterreich abcdefghijklmnopqrstuvwxyz', b''), encoding = 'iso-8859-1'
@pytest.mark.parametrize(
["data", "encoding"],
[
((b"Hello,", b" world!"), "ascii"),
((b"\xe3\x83", b"\x88\xe3\x83\xa9", b"\xe3", b"\x83\x99\xe3\x83\xab"), "utf-8"),
((b"Euro character: \x88! abcdefghijklmnopqrstuvwxyz", b""), "cp1252"),
((b"Accented: \xd6sterreich abcdefghijklmnopqrstuvwxyz", b""), "iso-8859-1"),
],
)
@pytest.mark.asyncio
async def test_text_decoder(data, encoding):
async def iterator():
nonlocal data
for chunk in data:
yield chunk
# Accessing `.text` on a read response.
response = httpx.Response(
200,
content=iterator(),
)
await response.aread()
> assert response.text == (b"".join(data)).decode(encoding)
E AssertionError: assert 'Accented: ųs...nopqrstuvwxyz' == 'Accented: Ös...nopqrstuvwxyz'
E - Accented: Österreich abcdefghijklmnopqrstuvwxyz
E ? ^
E + Accented: ųsterreich abcdefghijklmnopqrstuvwxyz
E ? ^
tests/test_decoders.py:199: AssertionError
________________________________________________________________________________ test_help _________________________________________________________________________________
self = <click.testing.CliRunner object at 0x7f6d045237f0>, cli = <function main at 0x7f6d0684da60>, args = ['--help'], input = None, env = None, catch_exceptions = True
color = False, extra = {}, exc_info = None, outstreams = (<_io.BytesIO object at 0x7f6d0457be00>, None), return_value = None, exception = None, exit_code = 0
def invoke(
self,
cli: "BaseCommand",
args: t.Optional[t.Union[str, t.Sequence[str]]] = None,
input: t.Optional[t.Union[str, bytes, t.IO]] = None,
env: t.Optional[t.Mapping[str, t.Optional[str]]] = None,
catch_exceptions: bool = True,
color: bool = False,
**extra: t.Any,
) -> Result:
"""Invokes a command in an isolated environment. The arguments are
forwarded directly to the command line script, the `extra` keyword
arguments are passed to the :meth:`~clickpkg.Command.main` function of
the command.
This returns a :class:`Result` object.
:param cli: the command to invoke
:param args: the arguments to invoke. It may be given as an iterable
or a string. When given as string it will be interpreted
as a Unix shell command. More details at
:func:`shlex.split`.
:param input: the input data for `sys.stdin`.
:param env: the environment overrides.
:param catch_exceptions: Whether to catch any other exceptions than
``SystemExit``.
:param extra: the keyword arguments to pass to :meth:`main`.
:param color: whether the output should contain color codes. The
application can still override this explicitly.
.. versionchanged:: 8.0
The result object has the ``return_value`` attribute with
the value returned from the invoked command.
.. versionchanged:: 4.0
Added the ``color`` parameter.
.. versionchanged:: 3.0
Added the ``catch_exceptions`` parameter.
.. versionchanged:: 3.0
The result object has the ``exc_info`` attribute with the
traceback if available.
"""
exc_info = None
with self.isolation(input=input, env=env, color=color) as outstreams:
return_value = None
exception: t.Optional[BaseException] = None
exit_code = 0
if isinstance(args, str):
args = shlex.split(args)
try:
> prog_name = extra.pop("prog_name")
E KeyError: 'prog_name'
/usr/lib/python3.8/site-packages/click/testing.py:403: KeyError
During handling of the above exception, another exception occurred:
def test_help():
runner = CliRunner()
> result = runner.invoke(httpx.main, ["--help"])
tests/test_main.py:18:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.8/site-packages/click/testing.py:405: in invoke
prog_name = self.get_default_prog_name(cli)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <click.testing.CliRunner object at 0x7f6d045237f0>, cli = <function main at 0x7f6d0684da60>
def get_default_prog_name(self, cli: "BaseCommand") -> str:
"""Given a command object it will return the default program name
for it. The default is the `name` attribute or ``"root"`` if not
set.
"""
> return cli.name or "root"
E AttributeError: 'function' object has no attribute 'name'
/usr/lib/python3.8/site-packages/click/testing.py:195: AttributeError
_________________________________________________________________________________ test_get _________________________________________________________________________________
self = <click.testing.CliRunner object at 0x7f6d04527970>, cli = <function main at 0x7f6d0684da60>, args = ['http://127.0.0.1:8000/'], input = None, env = None
catch_exceptions = True, color = False, extra = {}, exc_info = None, outstreams = (<_io.BytesIO object at 0x7f6d0450bef0>, None), return_value = None, exception = None
exit_code = 0
def invoke(
self,
cli: "BaseCommand",
args: t.Optional[t.Union[str, t.Sequence[str]]] = None,
input: t.Optional[t.Union[str, bytes, t.IO]] = None,
env: t.Optional[t.Mapping[str, t.Optional[str]]] = None,
catch_exceptions: bool = True,
color: bool = False,
**extra: t.Any,
) -> Result:
"""Invokes a command in an isolated environment. The arguments are
forwarded directly to the command line script, the `extra` keyword
arguments are passed to the :meth:`~clickpkg.Command.main` function of
the command.
This returns a :class:`Result` object.
:param cli: the command to invoke
:param args: the arguments to invoke. It may be given as an iterable
or a string. When given as string it will be interpreted
as a Unix shell command. More details at
:func:`shlex.split`.
:param input: the input data for `sys.stdin`.
:param env: the environment overrides.
:param catch_exceptions: Whether to catch any other exceptions than
``SystemExit``.
:param extra: the keyword arguments to pass to :meth:`main`.
:param color: whether the output should contain color codes. The
application can still override this explicitly.
.. versionchanged:: 8.0
The result object has the ``return_value`` attribute with
the value returned from the invoked command.
.. versionchanged:: 4.0
Added the ``color`` parameter.
.. versionchanged:: 3.0
Added the ``catch_exceptions`` parameter.
.. versionchanged:: 3.0
The result object has the ``exc_info`` attribute with the
traceback if available.
"""
exc_info = None
with self.isolation(input=input, env=env, color=color) as outstreams:
return_value = None
exception: t.Optional[BaseException] = None
exit_code = 0
if isinstance(args, str):
args = shlex.split(args)
try:
> prog_name = extra.pop("prog_name")
E KeyError: 'prog_name'
/usr/lib/python3.8/site-packages/click/testing.py:403: KeyError
During handling of the above exception, another exception occurred:
server = <tests.conftest.TestServer object at 0x7f6d05f182e0>
def test_get(server):
url = str(server.url)
runner = CliRunner()
> result = runner.invoke(httpx.main, [url])
tests/test_main.py:26:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.8/site-packages/click/testing.py:405: in invoke
prog_name = self.get_default_prog_name(cli)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <click.testing.CliRunner object at 0x7f6d04527970>, cli = <function main at 0x7f6d0684da60>
def get_default_prog_name(self, cli: "BaseCommand") -> str:
"""Given a command object it will return the default program name
for it. The default is the `name` attribute or ``"root"`` if not
set.
"""
> return cli.name or "root"
E AttributeError: 'function' object has no attribute 'name'
/usr/lib/python3.8/site-packages/click/testing.py:195: AttributeError
________________________________________________________________________________ test_json _________________________________________________________________________________
self = <click.testing.CliRunner object at 0x7f6d0454cca0>, cli = <function main at 0x7f6d0684da60>, args = ['http://127.0.0.1:8000/json'], input = None, env = None
catch_exceptions = True, color = False, extra = {}, exc_info = None, outstreams = (<_io.BytesIO object at 0x7f6d044cadb0>, None), return_value = None, exception = None
exit_code = 0
def invoke(
self,
cli: "BaseCommand",
args: t.Optional[t.Union[str, t.Sequence[str]]] = None,
input: t.Optional[t.Union[str, bytes, t.IO]] = None,
env: t.Optional[t.Mapping[str, t.Optional[str]]] = None,
catch_exceptions: bool = True,
color: bool = False,
**extra: t.Any,
) -> Result:
"""Invokes a command in an isolated environment. The arguments are
forwarded directly to the command line script, the `extra` keyword
arguments are passed to the :meth:`~clickpkg.Command.main` function of
the command.
This returns a :class:`Result` object.
:param cli: the command to invoke
:param args: the arguments to invoke. It may be given as an iterable
or a string. When given as string it will be interpreted
as a Unix shell command. More details at
:func:`shlex.split`.
:param input: the input data for `sys.stdin`.
:param env: the environment overrides.
:param catch_exceptions: Whether to catch any other exceptions than
``SystemExit``.
:param extra: the keyword arguments to pass to :meth:`main`.
:param color: whether the output should contain color codes. The
application can still override this explicitly.
.. versionchanged:: 8.0
The result object has the ``return_value`` attribute with
the value returned from the invoked command.
.. versionchanged:: 4.0
Added the ``color`` parameter.
.. versionchanged:: 3.0
Added the ``catch_exceptions`` parameter.
.. versionchanged:: 3.0
The result object has the ``exc_info`` attribute with the
traceback if available.
"""
exc_info = None
with self.isolation(input=input, env=env, color=color) as outstreams:
return_value = None
exception: t.Optional[BaseException] = None
exit_code = 0
if isinstance(args, str):
args = shlex.split(args)
try:
> prog_name = extra.pop("prog_name")
E KeyError: 'prog_name'
/usr/lib/python3.8/site-packages/click/testing.py:403: KeyError
During handling of the above exception, another exception occurred:
server = <tests.conftest.TestServer object at 0x7f6d05f182e0>
def test_json(server):
url = str(server.url.copy_with(path="/json"))
runner = CliRunner()
> result = runner.invoke(httpx.main, [url])
tests/test_main.py:41:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.8/site-packages/click/testing.py:405: in invoke
prog_name = self.get_default_prog_name(cli)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <click.testing.CliRunner object at 0x7f6d0454cca0>, cli = <function main at 0x7f6d0684da60>
def get_default_prog_name(self, cli: "BaseCommand") -> str:
"""Given a command object it will return the default program name
for it. The default is the `name` attribute or ``"root"`` if not
set.
"""
> return cli.name or "root"
E AttributeError: 'function' object has no attribute 'name'
/usr/lib/python3.8/site-packages/click/testing.py:195: AttributeError
______________________________________________________________________________ test_redirects ______________________________________________________________________________
self = <click.testing.CliRunner object at 0x7f6d04523670>, cli = <function main at 0x7f6d0684da60>, args = ['http://127.0.0.1:8000/redirect_301'], input = None, env = None
catch_exceptions = True, color = False, extra = {}, exc_info = None, outstreams = (<_io.BytesIO object at 0x7f6d0452bbd0>, None), return_value = None, exception = None
exit_code = 0
def invoke(
self,
cli: "BaseCommand",
args: t.Optional[t.Union[str, t.Sequence[str]]] = None,
input: t.Optional[t.Union[str, bytes, t.IO]] = None,
env: t.Optional[t.Mapping[str, t.Optional[str]]] = None,
catch_exceptions: bool = True,
color: bool = False,
**extra: t.Any,
) -> Result:
"""Invokes a command in an isolated environment. The arguments are
forwarded directly to the command line script, the `extra` keyword
arguments are passed to the :meth:`~clickpkg.Command.main` function of
the command.
This returns a :class:`Result` object.
:param cli: the command to invoke
:param args: the arguments to invoke. It may be given as an iterable
or a string. When given as string it will be interpreted
as a Unix shell command. More details at
:func:`shlex.split`.
:param input: the input data for `sys.stdin`.
:param env: the environment overrides.
:param catch_exceptions: Whether to catch any other exceptions than
``SystemExit``.
:param extra: the keyword arguments to pass to :meth:`main`.
:param color: whether the output should contain color codes. The
application can still override this explicitly.
.. versionchanged:: 8.0
The result object has the ``return_value`` attribute with
the value returned from the invoked command.
.. versionchanged:: 4.0
Added the ``color`` parameter.
.. versionchanged:: 3.0
Added the ``catch_exceptions`` parameter.
.. versionchanged:: 3.0
The result object has the ``exc_info`` attribute with the
traceback if available.
"""
exc_info = None
with self.isolation(input=input, env=env, color=color) as outstreams:
return_value = None
exception: t.Optional[BaseException] = None
exit_code = 0
if isinstance(args, str):
args = shlex.split(args)
try:
> prog_name = extra.pop("prog_name")
E KeyError: 'prog_name'
/usr/lib/python3.8/site-packages/click/testing.py:403: KeyError
During handling of the above exception, another exception occurred:
server = <tests.conftest.TestServer object at 0x7f6d05f182e0>
def test_redirects(server):
url = str(server.url.copy_with(path="/redirect_301"))
runner = CliRunner()
> result = runner.invoke(httpx.main, [url])
tests/test_main.py:58:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.8/site-packages/click/testing.py:405: in invoke
prog_name = self.get_default_prog_name(cli)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <click.testing.CliRunner object at 0x7f6d04523670>, cli = <function main at 0x7f6d0684da60>
def get_default_prog_name(self, cli: "BaseCommand") -> str:
"""Given a command object it will return the default program name
for it. The default is the `name` attribute or ``"root"`` if not
set.
"""
> return cli.name or "root"
E AttributeError: 'function' object has no attribute 'name'
/usr/lib/python3.8/site-packages/click/testing.py:195: AttributeError
__________________________________________________________________________ test_follow_redirects ___________________________________________________________________________
self = <click.testing.CliRunner object at 0x7f6d0454c070>, cli = <function main at 0x7f6d0684da60>, args = ['http://127.0.0.1:8000/redirect_301', '--follow-redirects']
input = None, env = None, catch_exceptions = True, color = False, extra = {}, exc_info = None, outstreams = (<_io.BytesIO object at 0x7f6d0450bd10>, None)
return_value = None, exception = None, exit_code = 0
def invoke(
self,
cli: "BaseCommand",
args: t.Optional[t.Union[str, t.Sequence[str]]] = None,
input: t.Optional[t.Union[str, bytes, t.IO]] = None,
env: t.Optional[t.Mapping[str, t.Optional[str]]] = None,
catch_exceptions: bool = True,
color: bool = False,
**extra: t.Any,
) -> Result:
"""Invokes a command in an isolated environment. The arguments are
forwarded directly to the command line script, the `extra` keyword
arguments are passed to the :meth:`~clickpkg.Command.main` function of
the command.
This returns a :class:`Result` object.
:param cli: the command to invoke
:param args: the arguments to invoke. It may be given as an iterable
or a string. When given as string it will be interpreted
as a Unix shell command. More details at
:func:`shlex.split`.
:param input: the input data for `sys.stdin`.
:param env: the environment overrides.
:param catch_exceptions: Whether to catch any other exceptions than
``SystemExit``.
:param extra: the keyword arguments to pass to :meth:`main`.
:param color: whether the output should contain color codes. The
application can still override this explicitly.
.. versionchanged:: 8.0
The result object has the ``return_value`` attribute with
the value returned from the invoked command.
.. versionchanged:: 4.0
Added the ``color`` parameter.
.. versionchanged:: 3.0
Added the ``catch_exceptions`` parameter.
.. versionchanged:: 3.0
The result object has the ``exc_info`` attribute with the
traceback if available.
"""
exc_info = None
with self.isolation(input=input, env=env, color=color) as outstreams:
return_value = None
exception: t.Optional[BaseException] = None
exit_code = 0
if isinstance(args, str):
args = shlex.split(args)
try:
> prog_name = extra.pop("prog_name")
E KeyError: 'prog_name'
/usr/lib/python3.8/site-packages/click/testing.py:403: KeyError
During handling of the above exception, another exception occurred:
server = <tests.conftest.TestServer object at 0x7f6d05f182e0>
def test_follow_redirects(server):
url = str(server.url.copy_with(path="/redirect_301"))
runner = CliRunner()
> result = runner.invoke(httpx.main, [url, "--follow-redirects"])
tests/test_main.py:72:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.8/site-packages/click/testing.py:405: in invoke
prog_name = self.get_default_prog_name(cli)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <click.testing.CliRunner object at 0x7f6d0454c070>, cli = <function main at 0x7f6d0684da60>
def get_default_prog_name(self, cli: "BaseCommand") -> str:
"""Given a command object it will return the default program name
for it. The default is the `name` attribute or ``"root"`` if not
set.
"""
> return cli.name or "root"
E AttributeError: 'function' object has no attribute 'name'
/usr/lib/python3.8/site-packages/click/testing.py:195: AttributeError
________________________________________________________________________________ test_post _________________________________________________________________________________
self = <click.testing.CliRunner object at 0x7f6d044be970>, cli = <function main at 0x7f6d0684da60>
args = ['http://127.0.0.1:8000/echo_body', '-m', 'POST', '-j', '{"hello": "world"}'], input = None, env = None, catch_exceptions = True, color = False, extra = {}
exc_info = None, outstreams = (<_io.BytesIO object at 0x7f6d04525900>, None), return_value = None, exception = None, exit_code = 0
def invoke(
self,
cli: "BaseCommand",
args: t.Optional[t.Union[str, t.Sequence[str]]] = None,
input: t.Optional[t.Union[str, bytes, t.IO]] = None,
env: t.Optional[t.Mapping[str, t.Optional[str]]] = None,
catch_exceptions: bool = True,
color: bool = False,
**extra: t.Any,
) -> Result:
"""Invokes a command in an isolated environment. The arguments are
forwarded directly to the command line script, the `extra` keyword
arguments are passed to the :meth:`~clickpkg.Command.main` function of
the command.
This returns a :class:`Result` object.
:param cli: the command to invoke
:param args: the arguments to invoke. It may be given as an iterable
or a string. When given as string it will be interpreted
as a Unix shell command. More details at
:func:`shlex.split`.
:param input: the input data for `sys.stdin`.
:param env: the environment overrides.
:param catch_exceptions: Whether to catch any other exceptions than
``SystemExit``.
:param extra: the keyword arguments to pass to :meth:`main`.
:param color: whether the output should contain color codes. The
application can still override this explicitly.
.. versionchanged:: 8.0
The result object has the ``return_value`` attribute with
the value returned from the invoked command.
.. versionchanged:: 4.0
Added the ``color`` parameter.
.. versionchanged:: 3.0
Added the ``catch_exceptions`` parameter.
.. versionchanged:: 3.0
The result object has the ``exc_info`` attribute with the
traceback if available.
"""
exc_info = None
with self.isolation(input=input, env=env, color=color) as outstreams:
return_value = None
exception: t.Optional[BaseException] = None
exit_code = 0
if isinstance(args, str):
args = shlex.split(args)
try:
> prog_name = extra.pop("prog_name")
E KeyError: 'prog_name'
/usr/lib/python3.8/site-packages/click/testing.py:403: KeyError
During handling of the above exception, another exception occurred:
server = <tests.conftest.TestServer object at 0x7f6d05f182e0>
def test_post(server):
url = str(server.url.copy_with(path="/echo_body"))
runner = CliRunner()
> result = runner.invoke(httpx.main, [url, "-m", "POST", "-j", '{"hello": "world"}'])
tests/test_main.py:92:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.8/site-packages/click/testing.py:405: in invoke
prog_name = self.get_default_prog_name(cli)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <click.testing.CliRunner object at 0x7f6d044be970>, cli = <function main at 0x7f6d0684da60>
def get_default_prog_name(self, cli: "BaseCommand") -> str:
"""Given a command object it will return the default program name
for it. The default is the `name` attribute or ``"root"`` if not
set.
"""
> return cli.name or "root"
E AttributeError: 'function' object has no attribute 'name'
/usr/lib/python3.8/site-packages/click/testing.py:195: AttributeError
_______________________________________________________________________________ test_verbose _______________________________________________________________________________
self = <click.testing.CliRunner object at 0x7f6d04527c40>, cli = <function main at 0x7f6d0684da60>, args = ['http://127.0.0.1:8000/', '-v'], input = None, env = None
catch_exceptions = True, color = False, extra = {}, exc_info = None, outstreams = (<_io.BytesIO object at 0x7f6d0450b900>, None), return_value = None, exception = None
exit_code = 0
def invoke(
self,
cli: "BaseCommand",
args: t.Optional[t.Union[str, t.Sequence[str]]] = None,
input: t.Optional[t.Union[str, bytes, t.IO]] = None,
env: t.Optional[t.Mapping[str, t.Optional[str]]] = None,
catch_exceptions: bool = True,
color: bool = False,
**extra: t.Any,
) -> Result:
"""Invokes a command in an isolated environment. The arguments are
forwarded directly to the command line script, the `extra` keyword
arguments are passed to the :meth:`~clickpkg.Command.main` function of
the command.
This returns a :class:`Result` object.
:param cli: the command to invoke
:param args: the arguments to invoke. It may be given as an iterable
or a string. When given as string it will be interpreted
as a Unix shell command. More details at
:func:`shlex.split`.
:param input: the input data for `sys.stdin`.
:param env: the environment overrides.
:param catch_exceptions: Whether to catch any other exceptions than
``SystemExit``.
:param extra: the keyword arguments to pass to :meth:`main`.
:param color: whether the output should contain color codes. The
application can still override this explicitly.
.. versionchanged:: 8.0
The result object has the ``return_value`` attribute with
the value returned from the invoked command.
.. versionchanged:: 4.0
Added the ``color`` parameter.
.. versionchanged:: 3.0
Added the ``catch_exceptions`` parameter.
.. versionchanged:: 3.0
The result object has the ``exc_info`` attribute with the
traceback if available.
"""
exc_info = None
with self.isolation(input=input, env=env, color=color) as outstreams:
return_value = None
exception: t.Optional[BaseException] = None
exit_code = 0
if isinstance(args, str):
args = shlex.split(args)
try:
> prog_name = extra.pop("prog_name")
E KeyError: 'prog_name'
/usr/lib/python3.8/site-packages/click/testing.py:403: KeyError
During handling of the above exception, another exception occurred:
server = <tests.conftest.TestServer object at 0x7f6d05f182e0>
def test_verbose(server):
url = str(server.url)
runner = CliRunner()
> result = runner.invoke(httpx.main, [url, "-v"])
tests/test_main.py:107:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.8/site-packages/click/testing.py:405: in invoke
prog_name = self.get_default_prog_name(cli)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <click.testing.CliRunner object at 0x7f6d04527c40>, cli = <function main at 0x7f6d0684da60>
def get_default_prog_name(self, cli: "BaseCommand") -> str:
"""Given a command object it will return the default program name
for it. The default is the `name` attribute or ``"root"`` if not
set.
"""
> return cli.name or "root"
E AttributeError: 'function' object has no attribute 'name'
/usr/lib/python3.8/site-packages/click/testing.py:195: AttributeError
________________________________________________________________________________ test_auth _________________________________________________________________________________
self = <click.testing.CliRunner object at 0x7f6d045420a0>, cli = <function main at 0x7f6d0684da60>
args = ['http://127.0.0.1:8000/', '-v', '--auth', 'username', 'password'], input = None, env = None, catch_exceptions = True, color = False, extra = {}, exc_info = None
outstreams = (<_io.BytesIO object at 0x7f6d0454f6d0>, None), return_value = None, exception = None, exit_code = 0
def invoke(
self,
cli: "BaseCommand",
args: t.Optional[t.Union[str, t.Sequence[str]]] = None,
input: t.Optional[t.Union[str, bytes, t.IO]] = None,
env: t.Optional[t.Mapping[str, t.Optional[str]]] = None,
catch_exceptions: bool = True,
color: bool = False,
**extra: t.Any,
) -> Result:
"""Invokes a command in an isolated environment. The arguments are
forwarded directly to the command line script, the `extra` keyword
arguments are passed to the :meth:`~clickpkg.Command.main` function of
the command.
This returns a :class:`Result` object.
:param cli: the command to invoke
:param args: the arguments to invoke. It may be given as an iterable
or a string. When given as string it will be interpreted
as a Unix shell command. More details at
:func:`shlex.split`.
:param input: the input data for `sys.stdin`.
:param env: the environment overrides.
:param catch_exceptions: Whether to catch any other exceptions than
``SystemExit``.
:param extra: the keyword arguments to pass to :meth:`main`.
:param color: whether the output should contain color codes. The
application can still override this explicitly.
.. versionchanged:: 8.0
The result object has the ``return_value`` attribute with
the value returned from the invoked command.
.. versionchanged:: 4.0
Added the ``color`` parameter.
.. versionchanged:: 3.0
Added the ``catch_exceptions`` parameter.
.. versionchanged:: 3.0
The result object has the ``exc_info`` attribute with the
traceback if available.
"""
exc_info = None
with self.isolation(input=input, env=env, color=color) as outstreams:
return_value = None
exception: t.Optional[BaseException] = None
exit_code = 0
if isinstance(args, str):
args = shlex.split(args)
try:
> prog_name = extra.pop("prog_name")
E KeyError: 'prog_name'
/usr/lib/python3.8/site-packages/click/testing.py:403: KeyError
During handling of the above exception, another exception occurred:
server = <tests.conftest.TestServer object at 0x7f6d05f182e0>
def test_auth(server):
url = str(server.url)
runner = CliRunner()
> result = runner.invoke(httpx.main, [url, "-v", "--auth", "username", "password"])
tests/test_main.py:131:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.8/site-packages/click/testing.py:405: in invoke
prog_name = self.get_default_prog_name(cli)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <click.testing.CliRunner object at 0x7f6d045420a0>, cli = <function main at 0x7f6d0684da60>
def get_default_prog_name(self, cli: "BaseCommand") -> str:
"""Given a command object it will return the default program name
for it. The default is the `name` attribute or ``"root"`` if not
set.
"""
> return cli.name or "root"
E AttributeError: 'function' object has no attribute 'name'
/usr/lib/python3.8/site-packages/click/testing.py:195: AttributeError
______________________________________________________________________________ test_download _______________________________________________________________________________
self = <click.testing.CliRunner object at 0x7f6d044d6850>, cli = <function main at 0x7f6d0684da60>, args = ['http://127.0.0.1:8000/', '--download', 'index.txt']
input = None, env = None, catch_exceptions = True, color = False, extra = {}, exc_info = None, outstreams = (<_io.BytesIO object at 0x7f6d0450fef0>, None)
return_value = None, exception = None, exit_code = 0
def invoke(
self,
cli: "BaseCommand",
args: t.Optional[t.Union[str, t.Sequence[str]]] = None,
input: t.Optional[t.Union[str, bytes, t.IO]] = None,
env: t.Optional[t.Mapping[str, t.Optional[str]]] = None,
catch_exceptions: bool = True,
color: bool = False,
**extra: t.Any,
) -> Result:
"""Invokes a command in an isolated environment. The arguments are
forwarded directly to the command line script, the `extra` keyword
arguments are passed to the :meth:`~clickpkg.Command.main` function of
the command.
This returns a :class:`Result` object.
:param cli: the command to invoke
:param args: the arguments to invoke. It may be given as an iterable
or a string. When given as string it will be interpreted
as a Unix shell command. More details at
:func:`shlex.split`.
:param input: the input data for `sys.stdin`.
:param env: the environment overrides.
:param catch_exceptions: Whether to catch any other exceptions than
``SystemExit``.
:param extra: the keyword arguments to pass to :meth:`main`.
:param color: whether the output should contain color codes. The
application can still override this explicitly.
.. versionchanged:: 8.0
The result object has the ``return_value`` attribute with
the value returned from the invoked command.
.. versionchanged:: 4.0
Added the ``color`` parameter.
.. versionchanged:: 3.0
Added the ``catch_exceptions`` parameter.
.. versionchanged:: 3.0
The result object has the ``exc_info`` attribute with the
traceback if available.
"""
exc_info = None
with self.isolation(input=input, env=env, color=color) as outstreams:
return_value = None
exception: t.Optional[BaseException] = None
exit_code = 0
if isinstance(args, str):
args = shlex.split(args)
try:
> prog_name = extra.pop("prog_name")
E KeyError: 'prog_name'
/usr/lib/python3.8/site-packages/click/testing.py:403: KeyError
During handling of the above exception, another exception occurred:
server = <tests.conftest.TestServer object at 0x7f6d05f182e0>
def test_download(server):
url = str(server.url)
runner = CliRunner()
with runner.isolated_filesystem():
> runner.invoke(httpx.main, [url, "--download", "index.txt"])
tests/test_main.py:158:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.8/site-packages/click/testing.py:405: in invoke
prog_name = self.get_default_prog_name(cli)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <click.testing.CliRunner object at 0x7f6d044d6850>, cli = <function main at 0x7f6d0684da60>
def get_default_prog_name(self, cli: "BaseCommand") -> str:
"""Given a command object it will return the default program name
for it. The default is the `name` attribute or ``"root"`` if not
set.
"""
> return cli.name or "root"
E AttributeError: 'function' object has no attribute 'name'
/usr/lib/python3.8/site-packages/click/testing.py:195: AttributeError
_______________________________________________________________________________ test_errors ________________________________________________________________________________
self = <click.testing.CliRunner object at 0x7f6d04586d90>, cli = <function main at 0x7f6d0684da60>, args = ['invalid://example.org'], input = None, env = None
catch_exceptions = True, color = False, extra = {}, exc_info = None, outstreams = (<_io.BytesIO object at 0x7f6d04579310>, None), return_value = None, exception = None
exit_code = 0
def invoke(
self,
cli: "BaseCommand",
args: t.Optional[t.Union[str, t.Sequence[str]]] = None,
input: t.Optional[t.Union[str, bytes, t.IO]] = None,
env: t.Optional[t.Mapping[str, t.Optional[str]]] = None,
catch_exceptions: bool = True,
color: bool = False,
**extra: t.Any,
) -> Result:
"""Invokes a command in an isolated environment. The arguments are
forwarded directly to the command line script, the `extra` keyword
arguments are passed to the :meth:`~clickpkg.Command.main` function of
the command.
This returns a :class:`Result` object.
:param cli: the command to invoke
:param args: the arguments to invoke. It may be given as an iterable
or a string. When given as string it will be interpreted
as a Unix shell command. More details at
:func:`shlex.split`.
:param input: the input data for `sys.stdin`.
:param env: the environment overrides.
:param catch_exceptions: Whether to catch any other exceptions than
``SystemExit``.
:param extra: the keyword arguments to pass to :meth:`main`.
:param color: whether the output should contain color codes. The
application can still override this explicitly.
.. versionchanged:: 8.0
The result object has the ``return_value`` attribute with
the value returned from the invoked command.
.. versionchanged:: 4.0
Added the ``color`` parameter.
.. versionchanged:: 3.0
Added the ``catch_exceptions`` parameter.
.. versionchanged:: 3.0
The result object has the ``exc_info`` attribute with the
traceback if available.
"""
exc_info = None
with self.isolation(input=input, env=env, color=color) as outstreams:
return_value = None
exception: t.Optional[BaseException] = None
exit_code = 0
if isinstance(args, str):
args = shlex.split(args)
try:
> prog_name = extra.pop("prog_name")
E KeyError: 'prog_name'
/usr/lib/python3.8/site-packages/click/testing.py:403: KeyError
During handling of the above exception, another exception occurred:
def test_errors():
runner = CliRunner()
> result = runner.invoke(httpx.main, ["invalid://example.org"])
tests/test_main.py:166:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.8/site-packages/click/testing.py:405: in invoke
prog_name = self.get_default_prog_name(cli)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <click.testing.CliRunner object at 0x7f6d04586d90>, cli = <function main at 0x7f6d0684da60>
def get_default_prog_name(self, cli: "BaseCommand") -> str:
"""Given a command object it will return the default program name
for it. The default is the `name` attribute or ``"root"`` if not
set.
"""
> return cli.name or "root"
E AttributeError: 'function' object has no attribute 'name'
/usr/lib/python3.8/site-packages/click/testing.py:195: AttributeError
_____________________________________________________________________________ test_socks_proxy _____________________________________________________________________________
def test_socks_proxy():
url = httpx.URL("http://www.example.com")
> client = httpx.Client(proxies="socks5://localhost/")
tests/client/test_proxies.py:53:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
httpx/_client.py:670: in __init__
self._mounts: typing.Dict[URLPattern, typing.Optional[BaseTransport]] = {
httpx/_client.py:673: in <dictcomp>
else self._init_proxy_transport(
httpx/_client.py:727: in _init_proxy_transport
return HTTPTransport(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <httpx.HTTPTransport object at 0x7f6d04436820>, verify = True, cert = None, http1 = True, http2 = False
limits = Limits(max_connections=100, max_keepalive_connections=20, keepalive_expiry=5.0), trust_env = True, proxy = Proxy('socks5://localhost/'), uds = None
local_address = None, retries = 0
def __init__(
self,
verify: VerifyTypes = True,
cert: CertTypes = None,
http1: bool = True,
http2: bool = False,
limits: Limits = DEFAULT_LIMITS,
trust_env: bool = True,
proxy: Proxy = None,
uds: str = None,
local_address: str = None,
retries: int = 0,
) -> None:
ssl_context = create_ssl_context(verify=verify, cert=cert, trust_env=trust_env)
if proxy is None:
self._pool = httpcore.ConnectionPool(
ssl_context=ssl_context,
max_connections=limits.max_connections,
max_keepalive_connections=limits.max_keepalive_connections,
keepalive_expiry=limits.keepalive_expiry,
http1=http1,
http2=http2,
uds=uds,
local_address=local_address,
retries=retries,
)
elif proxy.url.scheme in ("http", "https"):
self._pool = httpcore.HTTPProxy(
proxy_url=httpcore.URL(
scheme=proxy.url.raw_scheme,
host=proxy.url.raw_host,
port=proxy.url.port,
target=proxy.url.raw_path,
),
proxy_auth=proxy.raw_auth,
proxy_headers=proxy.headers.raw,
ssl_context=ssl_context,
max_connections=limits.max_connections,
max_keepalive_connections=limits.max_keepalive_connections,
keepalive_expiry=limits.keepalive_expiry,
http1=http1,
http2=http2,
)
elif proxy.url.scheme == "socks5":
try:
import socksio # noqa
except ImportError: # pragma: nocover
> raise ImportError(
"Using SOCKS proxy, but the 'socksio' package is not installed. "
"Make sure to install httpx using `pip install httpx[socks]`."
) from None
E ImportError: Using SOCKS proxy, but the 'socksio' package is not installed. Make sure to install httpx using `pip install httpx[socks]`.
httpx/_transports/default.py:161: ImportError
__________________________________________________________________________ test_async_proxy_close __________________________________________________________________________
map = {<class 'TimeoutError'>: <class 'httpcore.ConnectTimeout'>, <class 'OSError'>: <class 'httpcore.ConnectError'>, <class 'anyio.BrokenResourceError'>: <class 'httpcore.ConnectError'>}
@contextlib.contextmanager
def map_exceptions(map: Dict[Type, Type]) -> Iterator[None]:
try:
> yield
/usr/lib/python3.8/site-packages/httpcore/_exceptions.py:8:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <httpcore.backends.asyncio.AsyncIOBackend object at 0x7f6d0445c370>, host = 'example.com', port = 80, timeout = 5.0, local_address = None
async def connect_tcp(
self, host: str, port: int, timeout: float = None, local_address: str = None
) -> AsyncNetworkStream:
exc_map = {
TimeoutError: ConnectTimeout,
OSError: ConnectError,
anyio.BrokenResourceError: ConnectError,
}
with map_exceptions(exc_map):
with anyio.fail_after(timeout):
> stream: anyio.abc.ByteStream = await anyio.connect_tcp(
remote_host=host,
remote_port=port,
local_host=local_address,
)
/usr/lib/python3.8/site-packages/httpcore/backends/asyncio.py:101:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
remote_host = 'example.com', remote_port = 80
async def connect_tcp(
remote_host: IPAddressType, remote_port: int, *, local_host: Optional[IPAddressType] = None,
tls: bool = False, ssl_context: Optional[ssl.SSLContext] = None,
tls_standard_compatible: bool = True, tls_hostname: Optional[str] = None,
happy_eyeballs_delay: float = 0.25
) -> Union[SocketStream, TLSStream]:
"""
Connect to a host using the TCP protocol.
This function implements the stateless version of the Happy Eyeballs algorithm (RFC 6555).
If ``address`` is a host name that resolves to multiple IP addresses, each one is tried until
one connection attempt succeeds. If the first attempt does not connected within 250
milliseconds, a second attempt is started using the next address in the list, and so on.
On IPv6 enabled systems, an IPv6 address (if available) is tried first.
When the connection has been established, a TLS handshake will be done if either
``ssl_context`` or ``tls_hostname`` is not ``None``, or if ``tls`` is ``True``.
:param remote_host: the IP address or host name to connect to
:param remote_port: port on the target host to connect to
:param local_host: the interface address or name to bind the socket to before connecting
:param tls: ``True`` to do a TLS handshake with the connected stream and return a
:class:`~anyio.streams.tls.TLSStream` instead
:param ssl_context: the SSL context object to use (if omitted, a default context is created)
:param tls_standard_compatible: If ``True``, performs the TLS shutdown handshake before closing
the stream and requires that the server does this as well. Otherwise,
:exc:`~ssl.SSLEOFError` may be raised during reads from the stream.
Some protocols, such as HTTP, require this option to be ``False``.
See :meth:`~ssl.SSLContext.wrap_socket` for details.
:param tls_hostname: host name to check the server certificate against (defaults to the value
of ``remote_host``)
:param happy_eyeballs_delay: delay (in seconds) before starting the next connection attempt
:return: a socket stream object if no TLS handshake was done, otherwise a TLS stream
:raises OSError: if the connection attempt fails
"""
# Placed here due to https://github.com/python/mypy/issues/7057
connected_stream: Optional[SocketStream] = None
async def try_connect(remote_host: str, event: Event) -> None:
nonlocal connected_stream
try:
stream = await asynclib.connect_tcp(remote_host, remote_port, local_address)
except OSError as exc:
oserrors.append(exc)
return
else:
if connected_stream is None:
connected_stream = stream
tg.cancel_scope.cancel()
else:
await stream.aclose()
finally:
event.set()
asynclib = get_asynclib()
local_address: Optional[IPSockAddrType] = None
family = socket.AF_UNSPEC
if local_host:
gai_res = await getaddrinfo(str(local_host), None)
family, *_, local_address = gai_res[0]
target_host = str(remote_host)
try:
addr_obj = ip_address(remote_host)
except ValueError:
# getaddrinfo() will raise an exception if name resolution fails
> gai_res = await getaddrinfo(target_host, remote_port, family=family,
type=socket.SOCK_STREAM)
/usr/lib/python3.8/site-packages/anyio/_core/_sockets.py:152:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
host = 'example.com', port = 80
async def getaddrinfo(host: Union[bytearray, bytes, str], port: Union[str, int, None], *,
family: Union[int, AddressFamily] = 0, type: Union[int, SocketKind] = 0,
proto: int = 0, flags: int = 0) -> GetAddrInfoReturnType:
"""
Look up a numeric IP address given a host name.
Internationalized domain names are translated according to the (non-transitional) IDNA 2008
standard.
.. note:: 4-tuple IPv6 socket addresses are automatically converted to 2-tuples of
(host, port), unlike what :func:`socket.getaddrinfo` does.
:param host: host name
:param port: port number
:param family: socket family (`'AF_INET``, ...)
:param type: socket type (``SOCK_STREAM``, ...)
:param proto: protocol number
:param flags: flags to pass to upstream ``getaddrinfo()``
:return: list of tuples containing (family, type, proto, canonname, sockaddr)
.. seealso:: :func:`socket.getaddrinfo`
"""
# Handle unicode hostnames
if isinstance(host, str):
try:
encoded_host = host.encode('ascii')
except UnicodeEncodeError:
import idna
encoded_host = idna.encode(host, uts46=True)
else:
encoded_host = host
> gai_res = await get_asynclib().getaddrinfo(encoded_host, port, family=family, type=type,
proto=proto, flags=flags)
/usr/lib/python3.8/site-packages/anyio/_core/_sockets.py:419:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
host = b'example.com', port = 80
async def getaddrinfo(host: Union[bytearray, bytes, str], port: Union[str, int, None], *,
family: Union[int, AddressFamily] = 0, type: Union[int, SocketKind] = 0,
proto: int = 0, flags: int = 0) -> GetAddrInfoReturnType:
# https://github.com/python/typeshed/pull/4304
> result = await get_running_loop().getaddrinfo(
host, port, family=family, type=type, proto=proto, flags=flags) # type: ignore[arg-type]
/usr/lib/python3.8/site-packages/anyio/_backends/_asyncio.py:1551:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <_UnixSelectorEventLoop running=False closed=False debug=False>, host = b'example.com', port = 80
async def getaddrinfo(self, host, port, *,
family=0, type=0, proto=0, flags=0):
if self._debug:
getaddr_func = self._getaddrinfo_debug
else:
getaddr_func = socket.getaddrinfo
> return await self.run_in_executor(
None, getaddr_func, host, port, family, type, proto, flags)
/usr/lib64/python3.8/asyncio/base_events.py:825:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = None
def run(self):
if not self.future.set_running_or_notify_cancel():
return
try:
> result = self.fn(*self.args, **self.kwargs)
/usr/lib64/python3.8/concurrent/futures/thread.py:57:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
host = b'example.com', port = 80, family = <AddressFamily.AF_UNSPEC: 0>, type = <SocketKind.SOCK_STREAM: 1>, proto = 0, flags = 0
def getaddrinfo(host, port, family=0, type=0, proto=0, flags=0):
"""Resolve host and port into list of address info entries.
Translate the host/port argument into a sequence of 5-tuples that contain
all the necessary arguments for creating a socket connected to that service.
host is a domain name, a string representation of an IPv4/v6 address or
None. port is a string service name such as 'http', a numeric port number or
None. By passing None as the value of host and port, you can pass NULL to
the underlying C API.
The family, type and proto arguments can be optionally specified in order to
narrow the list of addresses returned. Passing zero as a value for each of
these arguments selects the full range of results.
"""
# We override this function since we want to translate the numeric family
# and socket type values to enum constants.
addrlist = []
> for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
E socket.gaierror: [Errno -2] Name or service not known
/usr/lib64/python3.8/socket.py:918: gaierror
During handling of the above exception, another exception occurred:
@contextlib.contextmanager
def map_httpcore_exceptions() -> typing.Iterator[None]:
try:
> yield
httpx/_transports/default.py:60:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <httpx.AsyncHTTPTransport object at 0x7f6d04459670>, request = <Request('GET', 'http://example.com')>
async def handle_async_request(
self,
request: Request,
) -> Response:
assert isinstance(request.stream, AsyncByteStream)
req = httpcore.Request(
method=request.method,
url=httpcore.URL(
scheme=request.url.raw_scheme,
host=request.url.raw_host,
port=request.url.port,
target=request.url.raw_path,
),
headers=request.headers.raw,
content=request.stream,
extensions=request.extensions,
)
with map_httpcore_exceptions():
> resp = await self._pool.handle_async_request(req)
httpx/_transports/default.py:353:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <httpcore.AsyncConnectionPool object at 0x7f6d04459bb0>, request = <Request [b'GET']>
async def handle_async_request(self, request: Request) -> Response:
"""
Send an HTTP request, and return an HTTP response.
This is the core implementation that is called into by `.request()` or `.stream()`.
"""
scheme = request.url.scheme.decode()
if scheme == "":
raise UnsupportedProtocol(
"Request URL is missing an 'http://' or 'https://' protocol."
)
if scheme not in ("http", "https"):
raise UnsupportedProtocol(
f"Request URL has an unsupported protocol '{scheme}://'."
)
status = RequestStatus(request)
async with self._pool_lock:
self._requests.append(status)
await self._close_expired_connections()
await self._attempt_to_acquire_connection(status)
while True:
timeouts = request.extensions.get("timeout", {})
timeout = timeouts.get("pool", None)
try:
connection = await status.wait_for_connection(timeout=timeout)
except BaseException as exc:
# If we timeout here, or if the task is cancelled, then make
# sure to remove the request from the queue before bubbling
# up the exception.
async with self._pool_lock:
self._requests.remove(status)
raise exc
try:
response = await connection.handle_async_request(request)
except ConnectionNotAvailable:
# The ConnectionNotAvailable exception is a special case, that
# indicates we need to retry the request on a new connection.
#
# The most common case where this can occur is when multiple
# requests are queued waiting for a single connection, which
# might end up as an HTTP/2 connection, but which actually ends
# up as HTTP/1.1.
async with self._pool_lock:
# Maintain our position in the request queue, but reset the
# status so that the request becomes queued again.
status.unset_connection()
await self._attempt_to_acquire_connection(status)
except BaseException as exc:
await self.response_closed(status)
> raise exc
/usr/lib/python3.8/site-packages/httpcore/_async/connection_pool.py:253:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <httpcore.AsyncConnectionPool object at 0x7f6d04459bb0>, request = <Request [b'GET']>
async def handle_async_request(self, request: Request) -> Response:
"""
Send an HTTP request, and return an HTTP response.
This is the core implementation that is called into by `.request()` or `.stream()`.
"""
scheme = request.url.scheme.decode()
if scheme == "":
raise UnsupportedProtocol(
"Request URL is missing an 'http://' or 'https://' protocol."
)
if scheme not in ("http", "https"):
raise UnsupportedProtocol(
f"Request URL has an unsupported protocol '{scheme}://'."
)
status = RequestStatus(request)
async with self._pool_lock:
self._requests.append(status)
await self._close_expired_connections()
await self._attempt_to_acquire_connection(status)
while True:
timeouts = request.extensions.get("timeout", {})
timeout = timeouts.get("pool", None)
try:
connection = await status.wait_for_connection(timeout=timeout)
except BaseException as exc:
# If we timeout here, or if the task is cancelled, then make
# sure to remove the request from the queue before bubbling
# up the exception.
async with self._pool_lock:
self._requests.remove(status)
raise exc
try:
> response = await connection.handle_async_request(request)
/usr/lib/python3.8/site-packages/httpcore/_async/connection_pool.py:237:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <AsyncHTTPConnection [CONNECTION FAILED]>, request = <Request [b'GET']>
async def handle_async_request(self, request: Request) -> Response:
if not self.can_handle_request(request.url.origin):
raise RuntimeError(
f"Attempted to send request to {request.url.origin} on connection to {self._origin}"
)
async with self._request_lock:
if self._connection is None:
try:
stream = await self._connect(request)
ssl_object = stream.get_extra_info("ssl_object")
http2_negotiated = (
ssl_object is not None
and ssl_object.selected_alpn_protocol() == "h2"
)
if http2_negotiated or (self._http2 and not self._http1):
from .http2 import AsyncHTTP2Connection
self._connection = AsyncHTTP2Connection(
origin=self._origin,
stream=stream,
keepalive_expiry=self._keepalive_expiry,
)
else:
self._connection = AsyncHTTP11Connection(
origin=self._origin,
stream=stream,
keepalive_expiry=self._keepalive_expiry,
)
except Exception as exc:
self._connect_failed = True
> raise exc
/usr/lib/python3.8/site-packages/httpcore/_async/connection.py:86:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <AsyncHTTPConnection [CONNECTION FAILED]>, request = <Request [b'GET']>
async def handle_async_request(self, request: Request) -> Response:
if not self.can_handle_request(request.url.origin):
raise RuntimeError(
f"Attempted to send request to {request.url.origin} on connection to {self._origin}"
)
async with self._request_lock:
if self._connection is None:
try:
> stream = await self._connect(request)
/usr/lib/python3.8/site-packages/httpcore/_async/connection.py:63:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <AsyncHTTPConnection [CONNECTION FAILED]>, request = <Request [b'GET']>
async def _connect(self, request: Request) -> AsyncNetworkStream:
timeouts = request.extensions.get("timeout", {})
timeout = timeouts.get("connect", None)
retries_left = self._retries
delays = exponential_backoff(factor=RETRIES_BACKOFF_FACTOR)
while True:
try:
if self._uds is None:
kwargs = {
"host": self._origin.host.decode("ascii"),
"port": self._origin.port,
"local_address": self._local_address,
"timeout": timeout,
}
async with Trace(
"connection.connect_tcp", request, kwargs
) as trace:
> stream = await self._network_backend.connect_tcp(**kwargs)
/usr/lib/python3.8/site-packages/httpcore/_async/connection.py:111:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <httpcore.backends.auto.AutoBackend object at 0x7f6d04459550>, host = 'example.com', port = 80, timeout = 5.0, local_address = None
async def connect_tcp(
self, host: str, port: int, timeout: float = None, local_address: str = None
) -> AsyncNetworkStream:
await self._init_backend()
> return await self._backend.connect_tcp(
host, port, timeout=timeout, local_address=local_address
)
/usr/lib/python3.8/site-packages/httpcore/backends/auto.py:23:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <httpcore.backends.asyncio.AsyncIOBackend object at 0x7f6d0445c370>, host = 'example.com', port = 80, timeout = 5.0, local_address = None
async def connect_tcp(
self, host: str, port: int, timeout: float = None, local_address: str = None
) -> AsyncNetworkStream:
exc_map = {
TimeoutError: ConnectTimeout,
OSError: ConnectError,
anyio.BrokenResourceError: ConnectError,
}
with map_exceptions(exc_map):
with anyio.fail_after(timeout):
> stream: anyio.abc.ByteStream = await anyio.connect_tcp(
remote_host=host,
remote_port=port,
local_host=local_address,
)
/usr/lib/python3.8/site-packages/httpcore/backends/asyncio.py:101:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <contextlib._GeneratorContextManager object at 0x7f6d0445cc70>, type = <class 'socket.gaierror'>, value = gaierror(-2, 'Name or service not known')
traceback = <traceback object at 0x7f6d04484f80>
def __exit__(self, type, value, traceback):
if type is None:
try:
next(self.gen)
except StopIteration:
return False
else:
raise RuntimeError("generator didn't stop")
else:
if value is None:
# Need to force instantiation so we can reliably
# tell if we get the same exception back
value = type()
try:
> self.gen.throw(type, value, traceback)
/usr/lib64/python3.8/contextlib.py:131:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
map = {<class 'TimeoutError'>: <class 'httpcore.ConnectTimeout'>, <class 'OSError'>: <class 'httpcore.ConnectError'>, <class 'anyio.BrokenResourceError'>: <class 'httpcore.ConnectError'>}
@contextlib.contextmanager
def map_exceptions(map: Dict[Type, Type]) -> 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)
E httpcore.ConnectError: [Errno -2] Name or service not known
/usr/lib/python3.8/site-packages/httpcore/_exceptions.py:12: ConnectError
The above exception was the direct cause of the following exception:
@pytest.mark.asyncio
@pytest.mark.network
async def test_async_proxy_close():
try:
client = httpx.AsyncClient(proxies={"https://": PROXY_URL})
> await client.get("http://example.com")
tests/client/test_proxies.py:140:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
httpx/_client.py:1729: in get
return await self.request(
httpx/_client.py:1506: in request
return await self.send(request, auth=auth, follow_redirects=follow_redirects)
httpx/_client.py:1593: in send
response = await self._send_handling_auth(
httpx/_client.py:1621: in _send_handling_auth
response = await self._send_handling_redirects(
httpx/_client.py:1658: in _send_handling_redirects
response = await self._send_single_request(request)
httpx/_client.py:1695: in _send_single_request
response = await transport.handle_async_request(request)
httpx/_transports/default.py:353: in handle_async_request
resp = await self._pool.handle_async_request(req)
/usr/lib64/python3.8/contextlib.py:131: in __exit__
self.gen.throw(type, value, traceback)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
@contextlib.contextmanager
def map_httpcore_exceptions() -> typing.Iterator[None]:
try:
yield
except Exception as exc: # noqa: PIE-786
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: nocover
raise
message = str(exc)
> raise mapped_exc(message) from exc
E httpx.ConnectError: [Errno -2] Name or service not known
httpx/_transports/default.py:77: ConnectError
__________________________________________________________________________ test_sync_proxy_close ___________________________________________________________________________
map = {<class 'socket.timeout'>: <class 'httpcore.ConnectTimeout'>, <class 'OSError'>: <class 'httpcore.ConnectError'>}
@contextlib.contextmanager
def map_exceptions(map: Dict[Type, Type]) -> Iterator[None]:
try:
> yield
/usr/lib/python3.8/site-packages/httpcore/_exceptions.py:8:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <httpcore.backends.sync.SyncBackend object at 0x7f6cff3ab4f0>, host = 'example.com', port = 80, timeout = 5.0, local_address = None
def connect_tcp(
self, host: str, port: int, timeout: float = None, local_address: str = None
) -> NetworkStream:
address = (host, port)
source_address = None if local_address is None else (local_address, 0)
exc_map = {socket.timeout: ConnectTimeout, socket.error: ConnectError}
with map_exceptions(exc_map):
> sock = socket.create_connection(
address, timeout, source_address=source_address
)
/usr/lib/python3.8/site-packages/httpcore/backends/sync.py:82:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
address = ('example.com', 80), timeout = 5.0, source_address = None
def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT,
source_address=None):
"""Connect to *address* and return the socket object.
Convenience function. Connect to *address* (a 2-tuple ``(host,
port)``) and return the socket object. Passing the optional
*timeout* parameter will set the timeout on the socket instance
before attempting to connect. If no *timeout* is supplied, the
global default timeout setting returned by :func:`getdefaulttimeout`
is used. If *source_address* is set it must be a tuple of (host, port)
for the socket to bind as a source address before making the connection.
A host of '' or port 0 tells the OS to use the default.
"""
host, port = address
err = None
> for res in getaddrinfo(host, port, 0, SOCK_STREAM):
/usr/lib64/python3.8/socket.py:787:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
host = 'example.com', port = 80, family = 0, type = <SocketKind.SOCK_STREAM: 1>, proto = 0, flags = 0
def getaddrinfo(host, port, family=0, type=0, proto=0, flags=0):
"""Resolve host and port into list of address info entries.
Translate the host/port argument into a sequence of 5-tuples that contain
all the necessary arguments for creating a socket connected to that service.
host is a domain name, a string representation of an IPv4/v6 address or
None. port is a string service name such as 'http', a numeric port number or
None. By passing None as the value of host and port, you can pass NULL to
the underlying C API.
The family, type and proto arguments can be optionally specified in order to
narrow the list of addresses returned. Passing zero as a value for each of
these arguments selects the full range of results.
"""
# We override this function since we want to translate the numeric family
# and socket type values to enum constants.
addrlist = []
> for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
E socket.gaierror: [Errno -2] Name or service not known
/usr/lib64/python3.8/socket.py:918: gaierror
During handling of the above exception, another exception occurred:
@contextlib.contextmanager
def map_httpcore_exceptions() -> typing.Iterator[None]:
try:
> yield
httpx/_transports/default.py:60:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <httpx.HTTPTransport object at 0x7f6cff3ab4c0>, request = <Request('GET', 'http://example.com')>
def handle_request(
self,
request: Request,
) -> Response:
assert isinstance(request.stream, SyncByteStream)
req = httpcore.Request(
method=request.method,
url=httpcore.URL(
scheme=request.url.raw_scheme,
host=request.url.raw_host,
port=request.url.port,
target=request.url.raw_path,
),
headers=request.headers.raw,
content=request.stream,
extensions=request.extensions,
)
with map_httpcore_exceptions():
> resp = self._pool.handle_request(req)
httpx/_transports/default.py:218:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <httpcore.ConnectionPool object at 0x7f6cff3ab430>, request = <Request [b'GET']>
def handle_request(self, request: Request) -> Response:
"""
Send an HTTP request, and return an HTTP response.
This is the core implementation that is called into by `.request()` or `.stream()`.
"""
scheme = request.url.scheme.decode()
if scheme == "":
raise UnsupportedProtocol(
"Request URL is missing an 'http://' or 'https://' protocol."
)
if scheme not in ("http", "https"):
raise UnsupportedProtocol(
f"Request URL has an unsupported protocol '{scheme}://'."
)
status = RequestStatus(request)
with self._pool_lock:
self._requests.append(status)
self._close_expired_connections()
self._attempt_to_acquire_connection(status)
while True:
timeouts = request.extensions.get("timeout", {})
timeout = timeouts.get("pool", None)
try:
connection = status.wait_for_connection(timeout=timeout)
except BaseException as exc:
# If we timeout here, or if the task is cancelled, then make
# sure to remove the request from the queue before bubbling
# up the exception.
with self._pool_lock:
self._requests.remove(status)
raise exc
try:
response = connection.handle_request(request)
except ConnectionNotAvailable:
# The ConnectionNotAvailable exception is a special case, that
# indicates we need to retry the request on a new connection.
#
# The most common case where this can occur is when multiple
# requests are queued waiting for a single connection, which
# might end up as an HTTP/2 connection, but which actually ends
# up as HTTP/1.1.
with self._pool_lock:
# Maintain our position in the request queue, but reset the
# status so that the request becomes queued again.
status.unset_connection()
self._attempt_to_acquire_connection(status)
except BaseException as exc:
self.response_closed(status)
> raise exc
/usr/lib/python3.8/site-packages/httpcore/_sync/connection_pool.py:253:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <httpcore.ConnectionPool object at 0x7f6cff3ab430>, request = <Request [b'GET']>
def handle_request(self, request: Request) -> Response:
"""
Send an HTTP request, and return an HTTP response.
This is the core implementation that is called into by `.request()` or `.stream()`.
"""
scheme = request.url.scheme.decode()
if scheme == "":
raise UnsupportedProtocol(
"Request URL is missing an 'http://' or 'https://' protocol."
)
if scheme not in ("http", "https"):
raise UnsupportedProtocol(
f"Request URL has an unsupported protocol '{scheme}://'."
)
status = RequestStatus(request)
with self._pool_lock:
self._requests.append(status)
self._close_expired_connections()
self._attempt_to_acquire_connection(status)
while True:
timeouts = request.extensions.get("timeout", {})
timeout = timeouts.get("pool", None)
try:
connection = status.wait_for_connection(timeout=timeout)
except BaseException as exc:
# If we timeout here, or if the task is cancelled, then make
# sure to remove the request from the queue before bubbling
# up the exception.
with self._pool_lock:
self._requests.remove(status)
raise exc
try:
> response = connection.handle_request(request)
/usr/lib/python3.8/site-packages/httpcore/_sync/connection_pool.py:237:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <HTTPConnection [CONNECTION FAILED]>, request = <Request [b'GET']>
def handle_request(self, request: Request) -> Response:
if not self.can_handle_request(request.url.origin):
raise RuntimeError(
f"Attempted to send request to {request.url.origin} on connection to {self._origin}"
)
with self._request_lock:
if self._connection is None:
try:
stream = self._connect(request)
ssl_object = stream.get_extra_info("ssl_object")
http2_negotiated = (
ssl_object is not None
and ssl_object.selected_alpn_protocol() == "h2"
)
if http2_negotiated or (self._http2 and not self._http1):
from .http2 import HTTP2Connection
self._connection = HTTP2Connection(
origin=self._origin,
stream=stream,
keepalive_expiry=self._keepalive_expiry,
)
else:
self._connection = HTTP11Connection(
origin=self._origin,
stream=stream,
keepalive_expiry=self._keepalive_expiry,
)
except Exception as exc:
self._connect_failed = True
> raise exc
/usr/lib/python3.8/site-packages/httpcore/_sync/connection.py:86:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <HTTPConnection [CONNECTION FAILED]>, request = <Request [b'GET']>
def handle_request(self, request: Request) -> Response:
if not self.can_handle_request(request.url.origin):
raise RuntimeError(
f"Attempted to send request to {request.url.origin} on connection to {self._origin}"
)
with self._request_lock:
if self._connection is None:
try:
> stream = self._connect(request)
/usr/lib/python3.8/site-packages/httpcore/_sync/connection.py:63:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <HTTPConnection [CONNECTION FAILED]>, request = <Request [b'GET']>
def _connect(self, request: Request) -> NetworkStream:
timeouts = request.extensions.get("timeout", {})
timeout = timeouts.get("connect", None)
retries_left = self._retries
delays = exponential_backoff(factor=RETRIES_BACKOFF_FACTOR)
while True:
try:
if self._uds is None:
kwargs = {
"host": self._origin.host.decode("ascii"),
"port": self._origin.port,
"local_address": self._local_address,
"timeout": timeout,
}
with Trace(
"connection.connect_tcp", request, kwargs
) as trace:
> stream = self._network_backend.connect_tcp(**kwargs)
/usr/lib/python3.8/site-packages/httpcore/_sync/connection.py:111:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <httpcore.backends.sync.SyncBackend object at 0x7f6cff3ab4f0>, host = 'example.com', port = 80, timeout = 5.0, local_address = None
def connect_tcp(
self, host: str, port: int, timeout: float = None, local_address: str = None
) -> NetworkStream:
address = (host, port)
source_address = None if local_address is None else (local_address, 0)
exc_map = {socket.timeout: ConnectTimeout, socket.error: ConnectError}
with map_exceptions(exc_map):
> sock = socket.create_connection(
address, timeout, source_address=source_address
)
/usr/lib/python3.8/site-packages/httpcore/backends/sync.py:82:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <contextlib._GeneratorContextManager object at 0x7f6cff3abc40>, type = <class 'socket.gaierror'>, value = gaierror(-2, 'Name or service not known')
traceback = <traceback object at 0x7f6cff71f5c0>
def __exit__(self, type, value, traceback):
if type is None:
try:
next(self.gen)
except StopIteration:
return False
else:
raise RuntimeError("generator didn't stop")
else:
if value is None:
# Need to force instantiation so we can reliably
# tell if we get the same exception back
value = type()
try:
> self.gen.throw(type, value, traceback)
/usr/lib64/python3.8/contextlib.py:131:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
map = {<class 'socket.timeout'>: <class 'httpcore.ConnectTimeout'>, <class 'OSError'>: <class 'httpcore.ConnectError'>}
@contextlib.contextmanager
def map_exceptions(map: Dict[Type, Type]) -> 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)
E httpcore.ConnectError: [Errno -2] Name or service not known
/usr/lib/python3.8/site-packages/httpcore/_exceptions.py:12: ConnectError
The above exception was the direct cause of the following exception:
@pytest.mark.network
def test_sync_proxy_close():
try:
client = httpx.Client(proxies={"https://": PROXY_URL})
> client.get("http://example.com")
tests/client/test_proxies.py:149:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
httpx/_client.py:1025: in get
return self.request(
httpx/_client.py:802: in request
return self.send(request, auth=auth, follow_redirects=follow_redirects)
httpx/_client.py:889: in send
response = self._send_handling_auth(
httpx/_client.py:917: in _send_handling_auth
response = self._send_handling_redirects(
httpx/_client.py:954: in _send_handling_redirects
response = self._send_single_request(request)
httpx/_client.py:990: in _send_single_request
response = transport.handle_request(request)
httpx/_transports/default.py:218: in handle_request
resp = self._pool.handle_request(req)
/usr/lib64/python3.8/contextlib.py:131: in __exit__
self.gen.throw(type, value, traceback)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
@contextlib.contextmanager
def map_httpcore_exceptions() -> typing.Iterator[None]:
try:
yield
except Exception as exc: # noqa: PIE-786
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: nocover
raise
message = str(exc)
> raise mapped_exc(message) from exc
E httpx.ConnectError: [Errno -2] Name or service not known
httpx/_transports/default.py:77: ConnectError
_____________________________________________________________ test_response_no_charset_with_iso_8859_1_content _____________________________________________________________
def test_response_no_charset_with_iso_8859_1_content():
"""
A response with ISO 8859-1 encoded content should decode correctly,
even with no charset specified.
"""
content = "Accented: Österreich abcdefghijklmnopqrstuzwxyz".encode("iso-8859-1")
headers = {"Content-Type": "text/plain"}
response = httpx.Response(
200,
content=content,
headers=headers,
)
> assert response.text == "Accented: Österreich abcdefghijklmnopqrstuzwxyz"
E AssertionError: assert 'Accented: ųs...nopqrstuzwxyz' == 'Accented: Ös...nopqrstuzwxyz'
E - Accented: Österreich abcdefghijklmnopqrstuzwxyz
E ? ^
E + Accented: ųsterreich abcdefghijklmnopqrstuzwxyz
E ? ^
tests/models/test_responses.py:240: AssertionError
============================================================================= warnings summary =============================================================================
tests/test_timeouts.py:26
/home/tkloczko/rpmbuild/BUILD/httpx-0.22.0/tests/test_timeouts.py:26: PytestUnknownMarkWarning: Unknown pytest.mark.network - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/mark.html
@pytest.mark.network
tests/client/test_proxies.py:136
/home/tkloczko/rpmbuild/BUILD/httpx-0.22.0/tests/client/test_proxies.py:136: PytestUnknownMarkWarning: Unknown pytest.mark.network - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/mark.html
@pytest.mark.network
tests/client/test_proxies.py:145
/home/tkloczko/rpmbuild/BUILD/httpx-0.22.0/tests/client/test_proxies.py:145: PytestUnknownMarkWarning: Unknown pytest.mark.network - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/mark.html
@pytest.mark.network
tests/test_asgi.py::test_asgi_transport[trio]
tests/test_asgi.py:73: PytestWarning: The test <Function test_asgi_transport[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/test_asgi.py::test_asgi_transport_no_body[trio]
tests/test_asgi.py:83: PytestWarning: The test <Function test_asgi_transport_no_body[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/test_asgi.py::test_asgi[trio]
tests/test_asgi.py:93: PytestWarning: The test <Function test_asgi[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/test_asgi.py::test_asgi_urlencoded_path[trio]
tests/test_asgi.py:102: PytestWarning: The test <Function test_asgi_urlencoded_path[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/test_asgi.py::test_asgi_raw_path[trio]
tests/test_asgi.py:112: PytestWarning: The test <Function test_asgi_raw_path[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/test_asgi.py::test_asgi_upload[trio]
tests/test_asgi.py:122: PytestWarning: The test <Function test_asgi_upload[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/test_asgi.py::test_asgi_headers[trio]
tests/test_asgi.py:131: PytestWarning: The test <Function test_asgi_headers[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/test_asgi.py::test_asgi_exc[trio]
tests/test_asgi.py:148: PytestWarning: The test <Function test_asgi_exc[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/test_asgi.py::test_asgi_exc_after_response[trio]
tests/test_asgi.py:155: PytestWarning: The test <Function test_asgi_exc_after_response[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/test_asgi.py::test_asgi_disconnect_after_response_complete[trio]
tests/test_asgi.py:162: PytestWarning: The test <Function test_asgi_disconnect_after_response_complete[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/test_timeouts.py::test_read_timeout[trio]
tests/test_timeouts.py:6: PytestWarning: The test <Function test_read_timeout[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/test_timeouts.py::test_write_timeout[trio]
tests/test_timeouts.py:15: PytestWarning: The test <Function test_write_timeout[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/test_timeouts.py::test_connect_timeout[trio]
tests/test_timeouts.py:25: PytestWarning: The test <Function test_connect_timeout[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/test_timeouts.py::test_pool_timeout[trio]
tests/test_timeouts.py:36: PytestWarning: The test <Function test_pool_timeout[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/client/test_async_client.py::test_get[trio]
tests/client/test_async_client.py:9: PytestWarning: The test <Function test_get[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/client/test_async_client.py::test_get_invalid_url[trio-scheme-not-http(s)]
tests/client/test_async_client.py:22: PytestWarning: The test <Function test_get_invalid_url[trio-scheme-not-http(s)]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.parametrize(
tests/client/test_async_client.py::test_get_invalid_url[trio-no-scheme]
tests/client/test_async_client.py:22: PytestWarning: The test <Function test_get_invalid_url[trio-no-scheme]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.parametrize(
tests/client/test_async_client.py::test_get_invalid_url[trio-no-host]
tests/client/test_async_client.py:22: PytestWarning: The test <Function test_get_invalid_url[trio-no-host]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.parametrize(
tests/client/test_async_client.py::test_build_request[trio]
tests/client/test_async_client.py:37: PytestWarning: The test <Function test_build_request[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/client/test_async_client.py::test_post[trio]
tests/client/test_async_client.py:52: PytestWarning: The test <Function test_post[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/client/test_async_client.py::test_post_json[trio]
tests/client/test_async_client.py:60: PytestWarning: The test <Function test_post_json[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/client/test_async_client.py::test_stream_response[trio]
tests/client/test_async_client.py:68: PytestWarning: The test <Function test_stream_response[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/client/test_async_client.py::test_access_content_stream_response[trio]
tests/client/test_async_client.py:79: PytestWarning: The test <Function test_access_content_stream_response[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/client/test_async_client.py::test_stream_request[trio]
tests/client/test_async_client.py:90: PytestWarning: The test <Function test_stream_request[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/client/test_async_client.py::test_cannot_stream_sync_request[trio]
tests/client/test_async_client.py:101: PytestWarning: The test <Function test_cannot_stream_sync_request[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/client/test_async_client.py::test_raise_for_status[trio]
tests/client/test_async_client.py:112: PytestWarning: The test <Function test_raise_for_status[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/client/test_async_client.py::test_options[trio]
tests/client/test_async_client.py:128: PytestWarning: The test <Function test_options[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/client/test_async_client.py::test_head[trio]
tests/client/test_async_client.py:136: PytestWarning: The test <Function test_head[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/client/test_async_client.py::test_put[trio]
tests/client/test_async_client.py:144: PytestWarning: The test <Function test_put[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/client/test_async_client.py::test_patch[trio]
tests/client/test_async_client.py:151: PytestWarning: The test <Function test_patch[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/client/test_async_client.py::test_delete[trio]
tests/client/test_async_client.py:158: PytestWarning: The test <Function test_delete[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/client/test_async_client.py::test_100_continue[trio]
tests/client/test_async_client.py:166: PytestWarning: The test <Function test_100_continue[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/client/test_async_client.py::test_context_managed_transport[trio]
tests/client/test_async_client.py:180: PytestWarning: The test <Function test_context_managed_transport[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/client/test_async_client.py::test_context_managed_transport_and_mount[trio]
tests/client/test_async_client.py:212: PytestWarning: The test <Function test_context_managed_transport_and_mount[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/client/test_async_client.py::test_client_closed_state_using_implicit_open[trio]
tests/client/test_async_client.py:257: PytestWarning: The test <Function test_client_closed_state_using_implicit_open[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/client/test_async_client.py::test_client_closed_state_using_with_block[trio]
tests/client/test_async_client.py:278: PytestWarning: The test <Function test_client_closed_state_using_with_block[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/client/test_async_client.py::test_mounted_transport[trio]
tests/client/test_async_client.py:299: PytestWarning: The test <Function test_mounted_transport[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/client/test_async_client.py::test_async_mock_transport[trio]
tests/client/test_async_client.py:314: PytestWarning: The test <Function test_async_mock_transport[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/client/test_async_client.py::test_server_extensions[trio]
tests/client/test_async_client.py:327: PytestWarning: The test <Function test_server_extensions[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/client/test_event_hooks.py::test_async_event_hooks[trio]
tests/client/test_event_hooks.py:66: PytestWarning: The test <Function test_async_event_hooks[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/client/test_event_hooks.py::test_async_event_hooks_raising_exception[trio]
tests/client/test_event_hooks.py:102: PytestWarning: The test <Function test_async_event_hooks_raising_exception[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/client/test_event_hooks.py::test_async_event_hooks_with_redirect[trio]
tests/client/test_event_hooks.py:174: PytestWarning: The test <Function test_async_event_hooks_with_redirect[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/client/test_redirects.py::test_async_next_request[trio]
tests/client/test_redirects.py:152: PytestWarning: The test <Function test_async_next_request[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/client/test_redirects.py::test_async_too_many_redirects[trio]
tests/client/test_redirects.py:241: PytestWarning: The test <Function test_async_too_many_redirects[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
tests/client/test_redirects.py::test_async_invalid_redirect[trio]
tests/client/test_redirects.py:421: PytestWarning: The test <Function test_async_invalid_redirect[trio]> is marked with '@pytest.mark.asyncio' but it is not an async function. Please remove asyncio marker. If the test is not marked explicitly, check for global markers applied via 'pytestmark'.
@pytest.mark.usefixtures("async_environment")
-- Docs: https://docs.pytest.org/en/stable/warnings.html
========================================================================= short test summary info ==========================================================================
FAILED tests/test_decoders.py::test_text_decoder[data3-iso-8859-1] - AssertionError: assert 'Accented: ųs...nopqrstuvwxyz' == 'Accented: Ös...nopqrstuvwxyz'
FAILED tests/test_main.py::test_help - AttributeError: 'function' object has no attribute 'name'
FAILED tests/test_main.py::test_get - AttributeError: 'function' object has no attribute 'name'
FAILED tests/test_main.py::test_json - AttributeError: 'function' object has no attribute 'name'
FAILED tests/test_main.py::test_redirects - AttributeError: 'function' object has no attribute 'name'
FAILED tests/test_main.py::test_follow_redirects - AttributeError: 'function' object has no attribute 'name'
FAILED tests/test_main.py::test_post - AttributeError: 'function' object has no attribute 'name'
FAILED tests/test_main.py::test_verbose - AttributeError: 'function' object has no attribute 'name'
FAILED tests/test_main.py::test_auth - AttributeError: 'function' object has no attribute 'name'
FAILED tests/test_main.py::test_download - AttributeError: 'function' object has no attribute 'name'
FAILED tests/test_main.py::test_errors - AttributeError: 'function' object has no attribute 'name'
FAILED tests/client/test_proxies.py::test_socks_proxy - ImportError: Using SOCKS proxy, but the 'socksio' package is not installed. Make sure to install httpx using `pip...
FAILED tests/client/test_proxies.py::test_async_proxy_close - httpx.ConnectError: [Errno -2] Name or service not known
FAILED tests/client/test_proxies.py::test_sync_proxy_close - httpx.ConnectError: [Errno -2] Name or service not known
FAILED tests/models/test_responses.py::test_response_no_charset_with_iso_8859_1_content - AssertionError: assert 'Accented: ųs...nopqrstuzwxyz' == 'Accented: Ös...nopqrs...
=============================================================== 15 failed, 661 passed, 48 warnings in 21.46s =============================================================== |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to package your module as an rpm package. So I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.
python3 -sBm build -w --no-isolationbuildwith--no-isolationI'm using during all processes only locally installed modulesHere is pytest output:
As I'm uising
trio0.20.0 above can be fixed by patch:Beta Was this translation helpful? Give feedback.
All reactions