Created attachment 723892 [details] build.log (0.18.1) [...] =============================================== FAILURES =============================================== __________________________ test_json_without_specified_encoding_decode_error ___________________________ def test_json_without_specified_encoding_decode_error(): data = {"greeting": "hello", "recipient": "world"} content = json.dumps(data).encode("utf-32-be") headers = {"Content-Type": "application/json"} # force incorrect guess from `guess_json_utf` to trigger error with mock.patch("httpx._models.guess_json_utf", return_value="utf-32"): response = httpx.Response( 200, content=content, headers=headers, ) with pytest.raises(json.decoder.JSONDecodeError): > response.json() E Failed: DID NOT RAISE <class 'json.decoder.JSONDecodeError'> content = (b'\x00\x00\x00{\x00\x00\x00"\x00\x00\x00g\x00\x00\x00r\x00\x00\x00e' b'\x00\x00\x00e\x00\x00\x00t\x00\x00\x00i\x00\x00\x00n\x00\x00\x00g' b'\x00\x00\x00"\x00\x00\x00:\x00\x00\x00 \x00\x00\x00"\x00\x00\x00h' b'\x00\x00\x00e\x00\x00\x00l\x00\x00\x00l\x00\x00\x00o\x00\x00\x00"' b'\x00\x00\x00,\x00\x00\x00 \x00\x00\x00"\x00\x00\x00r\x00\x00\x00e' b'\x00\x00\x00c\x00\x00\x00i\x00\x00\x00p\x00\x00\x00i\x00\x00\x00e' b'\x00\x00\x00n\x00\x00\x00t\x00\x00\x00"\x00\x00\x00:\x00\x00\x00 ' b'\x00\x00\x00"\x00\x00\x00w\x00\x00\x00o\x00\x00\x00r\x00\x00\x00l' b'\x00\x00\x00d\x00\x00\x00"\x00\x00\x00}') data = {'greeting': 'hello', 'recipient': 'world'} headers = {'Content-Type': 'application/json'} response = <Response [200 OK]> tests/models/test_responses.py:748: Failed ___________________________ test_json_without_specified_encoding_value_error ___________________________ def test_json_without_specified_encoding_value_error(): data = {"greeting": "hello", "recipient": "world"} content = json.dumps(data).encode("utf-32-be") headers = {"Content-Type": "application/json"} # force incorrect guess from `guess_json_utf` to trigger error with mock.patch("httpx._models.guess_json_utf", return_value="utf-32"): response = httpx.Response(200, content=content, headers=headers) with pytest.raises(json.decoder.JSONDecodeError): > response.json() E Failed: DID NOT RAISE <class 'json.decoder.JSONDecodeError'> content = (b'\x00\x00\x00{\x00\x00\x00"\x00\x00\x00g\x00\x00\x00r\x00\x00\x00e' b'\x00\x00\x00e\x00\x00\x00t\x00\x00\x00i\x00\x00\x00n\x00\x00\x00g' b'\x00\x00\x00"\x00\x00\x00:\x00\x00\x00 \x00\x00\x00"\x00\x00\x00h' b'\x00\x00\x00e\x00\x00\x00l\x00\x00\x00l\x00\x00\x00o\x00\x00\x00"' b'\x00\x00\x00,\x00\x00\x00 \x00\x00\x00"\x00\x00\x00r\x00\x00\x00e' b'\x00\x00\x00c\x00\x00\x00i\x00\x00\x00p\x00\x00\x00i\x00\x00\x00e' b'\x00\x00\x00n\x00\x00\x00t\x00\x00\x00"\x00\x00\x00:\x00\x00\x00 ' b'\x00\x00\x00"\x00\x00\x00w\x00\x00\x00o\x00\x00\x00r\x00\x00\x00l' b'\x00\x00\x00d\x00\x00\x00"\x00\x00\x00}') data = {'greeting': 'hello', 'recipient': 'world'} headers = {'Content-Type': 'application/json'} response = <Response [200 OK]> tests/models/test_responses.py:759: Failed [...] ======================================= short test summary info ======================================== SKIPPED [46] ../../../../../../../usr/lib/python3.9/site-packages/_pytest/python.py:173: async def function and no async plugin installed (see warnings) FAILED tests/models/test_responses.py::test_json_without_specified_encoding_decode_error - Failed: DI... FAILED tests/models/test_responses.py::test_json_without_specified_encoding_value_error - Failed: DID... ================ 2 failed, 594 passed, 46 skipped, 2 deselected, 52 warnings in 14.08s ================= * ERROR: dev-python/httpx-0.18.1::gentoo failed (test phase): * pytest failed with python3.9
Created attachment 723895 [details] emerge --info
Created attachment 723898 [details] build.log (0.18.2) 0.18.2 fails to run the testsuite at all: [...] >>> Test phase: dev-python/httpx-0.18.2 * python3_9: running distutils-r1_run_phase python_test python3.9 -m pytest -vv -ra -l -Wdefault --deselect tests/client/test_proxies.py::test_async_proxy_close --deselect tests/client/test_proxies.py::test_sync_proxy_close ImportError while loading conftest '/var/tmp/portage/dev-python/httpx-0.18.2/work/httpx-0.18.2/tests/conftest.py'. tests/conftest.py:17: in <module> from typing_extensions import Literal E ModuleNotFoundError: No module named 'typing_extensions' * ERROR: dev-python/httpx-0.18.2::gentoo failed (test phase): * pytest failed with python3.9
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=77abbe5810741f9fce7130d715483b2c9db3b332 commit 77abbe5810741f9fce7130d715483b2c9db3b332 Author: Michał Górny <mgorny@gentoo.org> AuthorDate: 2021-07-26 07:02:50 +0000 Commit: Michał Górny <mgorny@gentoo.org> CommitDate: 2021-07-26 07:03:14 +0000 dev-python/httpx: Add test-dep on typing-extensions Bug: https://bugs.gentoo.org/802195 Signed-off-by: Michał Górny <mgorny@gentoo.org> dev-python/httpx/httpx-0.18.1.ebuild | 1 + dev-python/httpx/httpx-0.18.2.ebuild | 1 + 2 files changed, 2 insertions(+)
Created attachment 728916 [details] build.log (0.18.2) The 2 tests still fail but with different output now. [...] __________________________ test_json_without_specified_encoding_decode_error ___________________________ def test_json_without_specified_encoding_decode_error(): data = {"greeting": "hello", "recipient": "world"} content = json.dumps(data).encode("utf-32-be") headers = {"Content-Type": "application/json"} # force incorrect guess from `guess_json_utf` to trigger error with mock.patch("httpx._models.guess_json_utf", return_value="utf-32"): response = httpx.Response( 200, content=content, headers=headers, ) with pytest.raises(json.decoder.JSONDecodeError): > response.json() E Failed: DID NOT RAISE <class 'json.decoder.JSONDecodeError'> content = (b'\x00\x00\x00{\x00\x00\x00"\x00\x00\x00g\x00\x00\x00r\x00\x00\x00e' b'\x00\x00\x00e\x00\x00\x00t\x00\x00\x00i\x00\x00\x00n\x00\x00\x00g' b'\x00\x00\x00"\x00\x00\x00:\x00\x00\x00 \x00\x00\x00"\x00\x00\x00h' b'\x00\x00\x00e\x00\x00\x00l\x00\x00\x00l\x00\x00\x00o\x00\x00\x00"' b'\x00\x00\x00,\x00\x00\x00 \x00\x00\x00"\x00\x00\x00r\x00\x00\x00e' b'\x00\x00\x00c\x00\x00\x00i\x00\x00\x00p\x00\x00\x00i\x00\x00\x00e' b'\x00\x00\x00n\x00\x00\x00t\x00\x00\x00"\x00\x00\x00:\x00\x00\x00 ' b'\x00\x00\x00"\x00\x00\x00w\x00\x00\x00o\x00\x00\x00r\x00\x00\x00l' b'\x00\x00\x00d\x00\x00\x00"\x00\x00\x00}') data = {'greeting': 'hello', 'recipient': 'world'} headers = {'Content-Type': 'application/json'} response = <Response [200 OK]> tests/models/test_responses.py:748: Failed ___________________________ test_json_without_specified_encoding_value_error ___________________________ def test_json_without_specified_encoding_value_error(): data = {"greeting": "hello", "recipient": "world"} content = json.dumps(data).encode("utf-32-be") headers = {"Content-Type": "application/json"} # force incorrect guess from `guess_json_utf` to trigger error with mock.patch("httpx._models.guess_json_utf", return_value="utf-32"): response = httpx.Response(200, content=content, headers=headers) with pytest.raises(json.decoder.JSONDecodeError): > response.json() E Failed: DID NOT RAISE <class 'json.decoder.JSONDecodeError'> content = (b'\x00\x00\x00{\x00\x00\x00"\x00\x00\x00g\x00\x00\x00r\x00\x00\x00e' b'\x00\x00\x00e\x00\x00\x00t\x00\x00\x00i\x00\x00\x00n\x00\x00\x00g' b'\x00\x00\x00"\x00\x00\x00:\x00\x00\x00 \x00\x00\x00"\x00\x00\x00h' b'\x00\x00\x00e\x00\x00\x00l\x00\x00\x00l\x00\x00\x00o\x00\x00\x00"' b'\x00\x00\x00,\x00\x00\x00 \x00\x00\x00"\x00\x00\x00r\x00\x00\x00e' b'\x00\x00\x00c\x00\x00\x00i\x00\x00\x00p\x00\x00\x00i\x00\x00\x00e' b'\x00\x00\x00n\x00\x00\x00t\x00\x00\x00"\x00\x00\x00:\x00\x00\x00 ' b'\x00\x00\x00"\x00\x00\x00w\x00\x00\x00o\x00\x00\x00r\x00\x00\x00l' b'\x00\x00\x00d\x00\x00\x00"\x00\x00\x00}') data = {'greeting': 'hello', 'recipient': 'world'} headers = {'Content-Type': 'application/json'} response = <Response [200 OK]> tests/models/test_responses.py:759: Failed =========================================== warnings summary =========================================== tests/test_timeouts.py::test_write_timeout[asyncio] /usr/lib/python3.9/asyncio/base_events.py:424: ResourceWarning: unclosed <socket.socket fd=22, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('127.0.0.1', 52400), raddr=('127.0.0.1', 8000)> return futures.Future(loop=self) tests/test_timeouts.py::test_write_timeout[asyncio] /usr/lib/python3.9/asyncio/selector_events.py:704: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=22> _warn(f"unclosed transport {self!r}", ResourceWarning, source=self) tests/client/test_async_client.py::test_100_continue[asyncio] /usr/lib/python3.9/asyncio/selector_events.py:704: ResourceWarning: unclosed transport <_SelectorSocketTransport fd=24> _warn(f"unclosed transport {self!r}", ResourceWarning, source=self) -- Docs: https://docs.pytest.org/en/stable/warnings.html ======================================= short test summary info ======================================== FAILED tests/models/test_responses.py::test_json_without_specified_encoding_decode_error - Failed: DI... FAILED tests/models/test_responses.py::test_json_without_specified_encoding_value_error - Failed: DID... ======================= 2 failed, 595 passed, 2 deselected, 3 warnings in 14.19s =======================
Also in 0.18.2 on sparc.
As Rolf correctly suggested, this seems to be an endianness issue. To confirm, I have run tests on our ppc64 and ppc64le hosts, and the former failed while the latter passed. I'm going to try fixing it.
Actually, it's not that hard: content = json.dumps(data).encode("utf-32-be") They force BE assuming that the host is LE and therefore BE will be incorrect...
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=aa113fa2e04b2036f6d2b73c3a2355673e5c27aa commit aa113fa2e04b2036f6d2b73c3a2355673e5c27aa Author: Michał Górny <mgorny@gentoo.org> AuthorDate: 2021-08-05 15:44:53 +0000 Commit: Michał Górny <mgorny@gentoo.org> CommitDate: 2021-08-05 15:50:24 +0000 dev-python/httpx: Fix tests on big endian platforms Closes: https://bugs.gentoo.org/802195 Signed-off-by: Michał Górny <mgorny@gentoo.org> .../httpx/files/httpx-0.18.2-big-endian.patch | 40 ++++++++++++++++++++++ dev-python/httpx/httpx-0.18.2.ebuild | 5 +++ 2 files changed, 45 insertions(+)