public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-python/pip/, dev-python/pip/files/
Date: Thu, 28 May 2020 18:35:32 +0000 (UTC)	[thread overview]
Message-ID: <1590690928.41fca3b9f6fca3210cb8241009b84ea344ceb489.mgorny@gentoo> (raw)

commit:     41fca3b9f6fca3210cb8241009b84ea344ceb489
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu May 28 18:33:31 2020 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu May 28 18:35:28 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=41fca3b9

dev-python/pip: Backport test fix for big endian

Signed-off-by: Michał Górny <mgorny <AT> gentoo.org>

 dev-python/pip/files/pip-20.1.1-test-endian.patch | 78 +++++++++++++++++++++++
 dev-python/pip/pip-20.1.1.ebuild                  |  1 +
 2 files changed, 79 insertions(+)

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
new file mode 100644
index 00000000000..b6aea145656
--- /dev/null
+++ b/dev-python/pip/files/pip-20.1.1-test-endian.patch
@@ -0,0 +1,78 @@
+From b30dd1e04e1f37901733f1be0a5a1e02c466ad0c Mon Sep 17 00:00:00 2001
+From: gutsytechster <prashantsharma161198@gmail.com>
+Date: Wed, 15 Apr 2020 19:54:48 +0530
+Subject: [PATCH] fix(tests/unit): Update tests to be endian safe
+
+This updates `test_path_to_display` and `test_str_to_display__encoding`
+to use the endian safe expected result instead of the hardcoded one.
+
+This fixes https://github.com/pypa/pip/issues/7921
+---
+ tests/unit/test_compat.py |  8 +++++++-
+ tests/unit/test_utils.py  | 16 +++++++++++++---
+ 2 files changed, 20 insertions(+), 4 deletions(-)
+
+diff --git a/tests/unit/test_compat.py b/tests/unit/test_compat.py
+index 1f31bc5c..b13087a1 100644
+--- a/tests/unit/test_compat.py
++++ b/tests/unit/test_compat.py
+@@ -2,6 +2,7 @@
+ 
+ import locale
+ import os
++import sys
+ 
+ import pytest
+ 
+@@ -91,8 +92,13 @@ def test_str_to_display__decode_error(monkeypatch, caplog):
+     # Encode with an incompatible encoding.
+     data = u'ab'.encode('utf-16')
+     actual = str_to_display(data)
++    # Keep the expected value endian safe
++    if sys.byteorder == "little":
++        expected = "\\xff\\xfea\x00b\x00"
++    elif sys.byteorder == "big":
++        expected = "\\xfe\\xff\x00a\x00b"
+ 
+-    assert actual == u'\\xff\\xfea\x00b\x00', (
++    assert actual == expected, (
+         # Show the encoding for easier troubleshooting.
+         'encoding: {!r}'.format(locale.getpreferredencoding())
+     )
+diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py
+index 7d74a664..ebabd29e 100644
+--- a/tests/unit/test_utils.py
++++ b/tests/unit/test_utils.py
+@@ -375,6 +375,18 @@ def test_rmtree_retries_for_3sec(tmpdir, monkeypatch):
+         rmtree('foo')
+ 
+ 
++if sys.byteorder == "little":
++    expected_byte_string = (
++        u"b'\\xff\\xfe/\\x00p\\x00a\\x00t\\x00h\\x00/"
++        "\\x00d\\x00\\xe9\\x00f\\x00'"
++    )
++elif sys.byteorder == "big":
++    expected_byte_string = (
++        u"b'\\xfe\\xff\\x00/\\x00p\\x00a\\x00t\\x00h\\"
++        "x00/\\x00d\\x00\\xe9\\x00f'"
++    )
++
++
+ @pytest.mark.parametrize('path, fs_encoding, expected', [
+     (None, None, None),
+     # Test passing a text (unicode) string.
+@@ -383,9 +395,7 @@ def test_rmtree_retries_for_3sec(tmpdir, monkeypatch):
+     (u'/path/déf'.encode('utf-8'), 'utf-8', u'/path/déf'),
+     # Test a bytes object with a character that can't be decoded.
+     (u'/path/déf'.encode('utf-8'), 'ascii', u"b'/path/d\\xc3\\xa9f'"),
+-    (u'/path/déf'.encode('utf-16'), 'utf-8',
+-     u"b'\\xff\\xfe/\\x00p\\x00a\\x00t\\x00h\\x00/"
+-     "\\x00d\\x00\\xe9\\x00f\\x00'"),
++    (u'/path/déf'.encode('utf-16'), 'utf-8', expected_byte_string),
+ ])
+ def test_path_to_display(monkeypatch, path, fs_encoding, expected):
+     monkeypatch.setattr(sys, 'getfilesystemencoding', lambda: fs_encoding)
+-- 
+2.26.2
+

diff --git a/dev-python/pip/pip-20.1.1.ebuild b/dev-python/pip/pip-20.1.1.ebuild
index 2d53216220c..adcd0cbcffd 100644
--- a/dev-python/pip/pip-20.1.1.ebuild
+++ b/dev-python/pip/pip-20.1.1.ebuild
@@ -56,6 +56,7 @@ DEPEND="
 python_prepare_all() {
 	local PATCHES=(
 		"${FILESDIR}/${PN}-19.3-disable-version-check.patch"
+		"${FILESDIR}/${P}-test-endian.patch"
 	)
 	if ! use vanilla; then
 		PATCHES+=( "${FILESDIR}/pip-20.0.2-disable-system-install.patch" )


             reply	other threads:[~2020-05-28 18:35 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-28 18:35 Michał Górny [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-11-09 16:46 [gentoo-commits] repo/gentoo:master commit in: dev-python/pip/, dev-python/pip/files/ Michał Górny
2024-11-09 13:30 Michał Górny
2024-06-23 17:33 Michał Górny
2024-06-22 16:39 Michał Górny
2023-04-15 19:39 Michał Górny
2022-07-21 20:17 Michał Górny
2022-06-12 14:25 Michał Górny
2022-05-22  7:13 Michał Górny
2021-10-23  8:44 Michał Górny
2021-08-01  8:17 Michał Górny
2021-06-09 20:17 Michał Górny
2021-04-25 10:36 Michał Górny
2020-07-29  8:03 Michał Górny
2020-07-29  8:03 Michał Górny
2020-02-22 20:22 Andreas Sturmlechner
2019-12-06  1:30 Patrick McLean
2019-10-22 20:38 Maxim Koltsov
2019-04-28  8:15 Maxim Koltsov
2018-06-26  3:39 Tim Harder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1590690928.41fca3b9f6fca3210cb8241009b84ea344ceb489.mgorny@gentoo \
    --to=mgorny@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox