mirror of
https://github.com/gentoo-mirror/gentoo.git
synced 2026-07-25 21:08:35 -07:00
dev-python/webencodings: Backport patch to fix tests
Package-Manager: portage-2.2.26 Signed-off-by: Justin Lecher <jlec@gentoo.org>
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
From 87044de0d2640cf9a8f941dec1fc79c679e7fa2d Mon Sep 17 00:00:00 2001
|
||||
From: Geoffrey Sneddon <me@gsnedders.com>
|
||||
Date: Sun, 17 Jan 2016 16:50:58 +0100
|
||||
Subject: [PATCH] Fix #2: get tests passing again after decode API change
|
||||
|
||||
---
|
||||
webencodings/tests.py | 36 ++++++++++++++++++------------------
|
||||
1 file changed, 18 insertions(+), 18 deletions(-)
|
||||
|
||||
diff --git a/webencodings/tests.py b/webencodings/tests.py
|
||||
index e0297d9..b8c5653 100644
|
||||
--- a/webencodings/tests.py
|
||||
+++ b/webencodings/tests.py
|
||||
@@ -47,7 +47,7 @@ def test_labels():
|
||||
|
||||
def test_all_labels():
|
||||
for label in LABELS:
|
||||
- assert decode(b'', label) == ''
|
||||
+ assert decode(b'', label) == ('', lookup(label))
|
||||
assert encode('', label) == b''
|
||||
for repeat in [0, 1, 12]:
|
||||
output, _ = iter_decode([b''] * repeat, label)
|
||||
@@ -74,25 +74,25 @@ def test_invalid_label():
|
||||
|
||||
|
||||
def test_decode():
|
||||
- assert decode(b'\x80', 'latin1') == '€'
|
||||
- assert decode(b'\x80', lookup('latin1')) == '€'
|
||||
- assert decode(b'\xc3\xa9', 'utf8') == 'é'
|
||||
- assert decode(b'\xc3\xa9', UTF8) == 'é'
|
||||
- assert decode(b'\xc3\xa9', 'ascii') == 'é'
|
||||
- assert decode(b'\xEF\xBB\xBF\xc3\xa9', 'ascii') == 'é' # UTF-8 with BOM
|
||||
+ assert decode(b'\x80', 'latin1') == ('€', lookup('latin1'))
|
||||
+ assert decode(b'\x80', lookup('latin1')) == ('€', lookup('latin1'))
|
||||
+ assert decode(b'\xc3\xa9', 'utf8') == ('é', lookup('utf8'))
|
||||
+ assert decode(b'\xc3\xa9', UTF8) == ('é', lookup('utf8'))
|
||||
+ assert decode(b'\xc3\xa9', 'ascii') == ('é', lookup('ascii'))
|
||||
+ assert decode(b'\xEF\xBB\xBF\xc3\xa9', 'ascii') == ('é', lookup('utf8')) # UTF-8 with BOM
|
||||
|
||||
- assert decode(b'\xFE\xFF\x00\xe9', 'ascii') == 'é' # UTF-16-BE with BOM
|
||||
- assert decode(b'\xFF\xFE\xe9\x00', 'ascii') == 'é' # UTF-16-LE with BOM
|
||||
- assert decode(b'\xFE\xFF\xe9\x00', 'ascii') == '\ue900'
|
||||
- assert decode(b'\xFF\xFE\x00\xe9', 'ascii') == '\ue900'
|
||||
+ assert decode(b'\xFE\xFF\x00\xe9', 'ascii') == ('é', lookup('utf-16be')) # UTF-16-BE with BOM
|
||||
+ assert decode(b'\xFF\xFE\xe9\x00', 'ascii') == ('é', lookup('utf-16le')) # UTF-16-LE with BOM
|
||||
+ assert decode(b'\xFE\xFF\xe9\x00', 'ascii') == ('\ue900', lookup('utf-16be'))
|
||||
+ assert decode(b'\xFF\xFE\x00\xe9', 'ascii') == ('\ue900', lookup('utf-16le'))
|
||||
|
||||
- assert decode(b'\x00\xe9', 'UTF-16BE') == 'é'
|
||||
- assert decode(b'\xe9\x00', 'UTF-16LE') == 'é'
|
||||
- assert decode(b'\xe9\x00', 'UTF-16') == 'é'
|
||||
+ assert decode(b'\x00\xe9', 'UTF-16BE') == ('é', lookup('utf-16be'))
|
||||
+ assert decode(b'\xe9\x00', 'UTF-16LE') == ('é', lookup('utf-16le'))
|
||||
+ assert decode(b'\xe9\x00', 'UTF-16') == ('é', lookup('utf-16le'))
|
||||
|
||||
- assert decode(b'\xe9\x00', 'UTF-16BE') == '\ue900'
|
||||
- assert decode(b'\x00\xe9', 'UTF-16LE') == '\ue900'
|
||||
- assert decode(b'\x00\xe9', 'UTF-16') == '\ue900'
|
||||
+ assert decode(b'\xe9\x00', 'UTF-16BE') == ('\ue900', lookup('utf-16be'))
|
||||
+ assert decode(b'\x00\xe9', 'UTF-16LE') == ('\ue900', lookup('utf-16le'))
|
||||
+ assert decode(b'\x00\xe9', 'UTF-16') == ('\ue900', lookup('utf-16le'))
|
||||
|
||||
|
||||
def test_encode():
|
||||
@@ -149,5 +149,5 @@ def test_x_user_defined():
|
||||
decoded = '2,\x0c\x0b\x1aO\uf7d9#\uf7cb\x0f\uf7c9\uf7bbt\uf7cf\uf7a8\uf7ca'
|
||||
encoded = b'aa'
|
||||
decoded = 'aa'
|
||||
- assert decode(encoded, 'x-user-defined') == decoded
|
||||
+ assert decode(encoded, 'x-user-defined') == (decoded, lookup('x-user-defined'))
|
||||
assert encode(decoded, 'x-user-defined') == encoded
|
||||
@@ -24,13 +24,18 @@ DEPEND="${REDEPEND}
|
||||
dev-python/pytest[${PYTHON_USEDEP}]
|
||||
)"
|
||||
|
||||
# https://github.com/SimonSapin/python-webencodings/issues/2
|
||||
RESTRICT=test
|
||||
PATCHES=(
|
||||
"${FILESDIR}"/${P}-test-fix-backport.patch
|
||||
)
|
||||
|
||||
python_test() {
|
||||
python_prepare_all(){
|
||||
cat >> setup.cfg <<- EOF
|
||||
[pytest]
|
||||
python_files=test*.py
|
||||
EOF
|
||||
distutils-r1_python_prepare_all
|
||||
}
|
||||
|
||||
python_test() {
|
||||
py.test -v -v || die
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user