commit:     8239792739f7a1f227c950cdc92f8fefefc9e98f
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 10 05:39:03 2024 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Jul 10 05:39:47 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=82397927

dev-python/importlib-resources: Fix tests on big endian

Closes: https://bugs.gentoo.org/935804
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 .../files/importlib-resources-6.4.0-be.patch       | 40 ++++++++++++++++++++++
 .../importlib-resources-6.4.0.ebuild               |  5 +++
 2 files changed, 45 insertions(+)

diff --git 
a/dev-python/importlib-resources/files/importlib-resources-6.4.0-be.patch 
b/dev-python/importlib-resources/files/importlib-resources-6.4.0-be.patch
new file mode 100644
index 000000000000..a4c20249af4f
--- /dev/null
+++ b/dev-python/importlib-resources/files/importlib-resources-6.4.0-be.patch
@@ -0,0 +1,40 @@
+From 3167e4b9de35ea3010d84429b7eafb9a7c2afbb4 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <[email protected]>
+Date: Wed, 10 Jul 2024 07:33:47 +0200
+Subject: [PATCH] Fix functional API tests to be endian-agnostic
+
+Fix the "backslashreplace" tests for the functional API to be
+endian-agnostic.  The tests used to rely on `.encode("utf-16")`
+producing the same data as found in the test file.  However, on big
+endian platforms it would produce a big endian encoding, while the test
+file is little endian.  To avoid the problem, explicitly specify
+`utf-16-le` encoding.  Since this meant that the BOM is no longer
+produced, explicitly include it in input.
+
+Fixes #312
+---
+ importlib_resources/tests/test_functional.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/importlib_resources/tests/test_functional.py 
b/importlib_resources/tests/test_functional.py
+index 69706cf..255bd13 100644
+--- a/importlib_resources/tests/test_functional.py
++++ b/importlib_resources/tests/test_functional.py
+@@ -82,7 +82,7 @@ def test_read_text(self):
+                 'utf-16.file',
+                 errors='backslashreplace',
+             ),
+-            'Hello, UTF-16 world!\n'.encode('utf-16').decode(
++            '\ufeffHello, UTF-16 world!\n'.encode('utf-16-le').decode(
+                 errors='backslashreplace',
+             ),
+         )
+@@ -130,7 +130,7 @@ def test_open_text(self):
+         ) as f:
+             self.assertEqual(
+                 f.read(),
+-                'Hello, UTF-16 world!\n'.encode('utf-16').decode(
++                '\ufeffHello, UTF-16 world!\n'.encode('utf-16-le').decode(
+                     errors='backslashreplace',
+                 ),
+             )

diff --git a/dev-python/importlib-resources/importlib-resources-6.4.0.ebuild 
b/dev-python/importlib-resources/importlib-resources-6.4.0.ebuild
index 277d817655e9..a79348c3becd 100644
--- a/dev-python/importlib-resources/importlib-resources-6.4.0.ebuild
+++ b/dev-python/importlib-resources/importlib-resources-6.4.0.ebuild
@@ -28,3 +28,8 @@ BDEPEND="
 "
 
 distutils_enable_tests unittest
+
+PATCHES=(
+       # https://github.com/python/importlib_resources/pull/313
+       "${FILESDIR}/${P}-be.patch"
+)

Reply via email to