1 |
commit: 41fca3b9f6fca3210cb8241009b84ea344ceb489 |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu May 28 18:33:31 2020 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu May 28 18:35:28 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=41fca3b9 |
7 |
|
8 |
dev-python/pip: Backport test fix for big endian |
9 |
|
10 |
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> |
11 |
|
12 |
dev-python/pip/files/pip-20.1.1-test-endian.patch | 78 +++++++++++++++++++++++ |
13 |
dev-python/pip/pip-20.1.1.ebuild | 1 + |
14 |
2 files changed, 79 insertions(+) |
15 |
|
16 |
diff --git a/dev-python/pip/files/pip-20.1.1-test-endian.patch b/dev-python/pip/files/pip-20.1.1-test-endian.patch |
17 |
new file mode 100644 |
18 |
index 00000000000..b6aea145656 |
19 |
--- /dev/null |
20 |
+++ b/dev-python/pip/files/pip-20.1.1-test-endian.patch |
21 |
@@ -0,0 +1,78 @@ |
22 |
+From b30dd1e04e1f37901733f1be0a5a1e02c466ad0c Mon Sep 17 00:00:00 2001 |
23 |
+From: gutsytechster <prashantsharma161198@×××××.com> |
24 |
+Date: Wed, 15 Apr 2020 19:54:48 +0530 |
25 |
+Subject: [PATCH] fix(tests/unit): Update tests to be endian safe |
26 |
+ |
27 |
+This updates `test_path_to_display` and `test_str_to_display__encoding` |
28 |
+to use the endian safe expected result instead of the hardcoded one. |
29 |
+ |
30 |
+This fixes https://github.com/pypa/pip/issues/7921 |
31 |
+--- |
32 |
+ tests/unit/test_compat.py | 8 +++++++- |
33 |
+ tests/unit/test_utils.py | 16 +++++++++++++--- |
34 |
+ 2 files changed, 20 insertions(+), 4 deletions(-) |
35 |
+ |
36 |
+diff --git a/tests/unit/test_compat.py b/tests/unit/test_compat.py |
37 |
+index 1f31bc5c..b13087a1 100644 |
38 |
+--- a/tests/unit/test_compat.py |
39 |
++++ b/tests/unit/test_compat.py |
40 |
+@@ -2,6 +2,7 @@ |
41 |
+ |
42 |
+ import locale |
43 |
+ import os |
44 |
++import sys |
45 |
+ |
46 |
+ import pytest |
47 |
+ |
48 |
+@@ -91,8 +92,13 @@ def test_str_to_display__decode_error(monkeypatch, caplog): |
49 |
+ # Encode with an incompatible encoding. |
50 |
+ data = u'ab'.encode('utf-16') |
51 |
+ actual = str_to_display(data) |
52 |
++ # Keep the expected value endian safe |
53 |
++ if sys.byteorder == "little": |
54 |
++ expected = "\\xff\\xfea\x00b\x00" |
55 |
++ elif sys.byteorder == "big": |
56 |
++ expected = "\\xfe\\xff\x00a\x00b" |
57 |
+ |
58 |
+- assert actual == u'\\xff\\xfea\x00b\x00', ( |
59 |
++ assert actual == expected, ( |
60 |
+ # Show the encoding for easier troubleshooting. |
61 |
+ 'encoding: {!r}'.format(locale.getpreferredencoding()) |
62 |
+ ) |
63 |
+diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py |
64 |
+index 7d74a664..ebabd29e 100644 |
65 |
+--- a/tests/unit/test_utils.py |
66 |
++++ b/tests/unit/test_utils.py |
67 |
+@@ -375,6 +375,18 @@ def test_rmtree_retries_for_3sec(tmpdir, monkeypatch): |
68 |
+ rmtree('foo') |
69 |
+ |
70 |
+ |
71 |
++if sys.byteorder == "little": |
72 |
++ expected_byte_string = ( |
73 |
++ u"b'\\xff\\xfe/\\x00p\\x00a\\x00t\\x00h\\x00/" |
74 |
++ "\\x00d\\x00\\xe9\\x00f\\x00'" |
75 |
++ ) |
76 |
++elif sys.byteorder == "big": |
77 |
++ expected_byte_string = ( |
78 |
++ u"b'\\xfe\\xff\\x00/\\x00p\\x00a\\x00t\\x00h\\" |
79 |
++ "x00/\\x00d\\x00\\xe9\\x00f'" |
80 |
++ ) |
81 |
++ |
82 |
++ |
83 |
+ @pytest.mark.parametrize('path, fs_encoding, expected', [ |
84 |
+ (None, None, None), |
85 |
+ # Test passing a text (unicode) string. |
86 |
+@@ -383,9 +395,7 @@ def test_rmtree_retries_for_3sec(tmpdir, monkeypatch): |
87 |
+ (u'/path/déf'.encode('utf-8'), 'utf-8', u'/path/déf'), |
88 |
+ # Test a bytes object with a character that can't be decoded. |
89 |
+ (u'/path/déf'.encode('utf-8'), 'ascii', u"b'/path/d\\xc3\\xa9f'"), |
90 |
+- (u'/path/déf'.encode('utf-16'), 'utf-8', |
91 |
+- u"b'\\xff\\xfe/\\x00p\\x00a\\x00t\\x00h\\x00/" |
92 |
+- "\\x00d\\x00\\xe9\\x00f\\x00'"), |
93 |
++ (u'/path/déf'.encode('utf-16'), 'utf-8', expected_byte_string), |
94 |
+ ]) |
95 |
+ def test_path_to_display(monkeypatch, path, fs_encoding, expected): |
96 |
+ monkeypatch.setattr(sys, 'getfilesystemencoding', lambda: fs_encoding) |
97 |
+-- |
98 |
+2.26.2 |
99 |
+ |
100 |
|
101 |
diff --git a/dev-python/pip/pip-20.1.1.ebuild b/dev-python/pip/pip-20.1.1.ebuild |
102 |
index 2d53216220c..adcd0cbcffd 100644 |
103 |
--- a/dev-python/pip/pip-20.1.1.ebuild |
104 |
+++ b/dev-python/pip/pip-20.1.1.ebuild |
105 |
@@ -56,6 +56,7 @@ DEPEND=" |
106 |
python_prepare_all() { |
107 |
local PATCHES=( |
108 |
"${FILESDIR}/${PN}-19.3-disable-version-check.patch" |
109 |
+ "${FILESDIR}/${P}-test-endian.patch" |
110 |
) |
111 |
if ! use vanilla; then |
112 |
PATCHES+=( "${FILESDIR}/pip-20.0.2-disable-system-install.patch" ) |