diff options
author | Michał Górny <mgorny@gentoo.org> | 2021-08-05 17:44:53 +0200 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2021-08-05 17:50:24 +0200 |
commit | aa113fa2e04b2036f6d2b73c3a2355673e5c27aa (patch) | |
tree | 12d793175589a7cb405f6db49749482711f2df3b /dev-python/httpx | |
parent | app-backup/duplicity: revert allarches (diff) | |
download | gentoo-aa113fa2e04b2036f6d2b73c3a2355673e5c27aa.tar.gz gentoo-aa113fa2e04b2036f6d2b73c3a2355673e5c27aa.tar.bz2 gentoo-aa113fa2e04b2036f6d2b73c3a2355673e5c27aa.zip |
dev-python/httpx: Fix tests on big endian platforms
Closes: https://bugs.gentoo.org/802195
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'dev-python/httpx')
-rw-r--r-- | dev-python/httpx/files/httpx-0.18.2-big-endian.patch | 40 | ||||
-rw-r--r-- | dev-python/httpx/httpx-0.18.2.ebuild | 5 |
2 files changed, 45 insertions, 0 deletions
diff --git a/dev-python/httpx/files/httpx-0.18.2-big-endian.patch b/dev-python/httpx/files/httpx-0.18.2-big-endian.patch new file mode 100644 index 000000000000..794609d86a50 --- /dev/null +++ b/dev-python/httpx/files/httpx-0.18.2-big-endian.patch @@ -0,0 +1,40 @@ +From 88a0a85ff795d8c23d5cd2cd113eeac957cc818a Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org> +Date: Thu, 5 Aug 2021 17:35:54 +0200 +Subject: [PATCH] Fix JSON wrong encoding tests on big endian platforms + +Fix test_json_without_specified_encoding_*_error tests on big endian +platforms. The tests wrongly assume that data encoded as "utf-32-be" +can not be decoded as "utf-32". This is true on little endian platforms +but on big endian platforms "utf-32" is equivalent to "utf-32-be". +To avoid the problem, explicitly decode as "utf-32-le", as this should +trigger the expected exception independently of platform's endianness. +--- + tests/models/test_responses.py | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/tests/models/test_responses.py b/tests/models/test_responses.py +index f1815dc..b7c2d57 100644 +--- a/tests/models/test_responses.py ++++ b/tests/models/test_responses.py +@@ -735,7 +735,7 @@ def test_json_without_specified_encoding_decode_error(): + 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"): ++ with mock.patch("httpx._models.guess_json_utf", return_value="utf-32-le"): + response = httpx.Response( + 200, + content=content, +@@ -750,7 +750,7 @@ def test_json_without_specified_encoding_value_error(): + 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"): ++ with mock.patch("httpx._models.guess_json_utf", return_value="utf-32-le"): + response = httpx.Response(200, content=content, headers=headers) + with pytest.raises(json.decoder.JSONDecodeError): + response.json() +-- +2.32.0 + diff --git a/dev-python/httpx/httpx-0.18.2.ebuild b/dev-python/httpx/httpx-0.18.2.ebuild index 4a3ce240ce3a..04a60d9a1033 100644 --- a/dev-python/httpx/httpx-0.18.2.ebuild +++ b/dev-python/httpx/httpx-0.18.2.ebuild @@ -40,6 +40,11 @@ BDEPEND=" distutils_enable_tests pytest +PATCHES=( + # https://github.com/encode/httpx/pull/1781 + "${FILESDIR}"/${P}-big-endian.patch +) + python_prepare_all() { # trio is not currently in the tree sed -i '/^import trio/d' tests/concurrency.py || die |