mirror of
https://github.com/gentoo-mirror/gentoo.git
synced 2026-07-25 21:08:35 -07:00
dev-python/cbor: Fix test failure bug 719648
Adds trivial patches to main code, fixes test_cbor.py test_sortkeys() wrongly assuming dictionary keys may not always be sorted when added in sorted order. Fix the test phase not finding the c extension module. Update metadata.xml to github repo. Package-Manager: Portage-2.3.99, Repoman-2.3.22 Signed-off-by: Brian Dolbec <dolsen@gentoo.org>
This commit is contained in:
40
dev-python/cbor/cbor-1.0.0-r1.ebuild
Normal file
40
dev-python/cbor/cbor-1.0.0-r1.ebuild
Normal file
@@ -0,0 +1,40 @@
|
||||
# Copyright 1999-2020 Gentoo Authors
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
|
||||
EAPI=7
|
||||
PYTHON_COMPAT=( python3_{6,7,8} )
|
||||
|
||||
inherit distutils-r1
|
||||
|
||||
EGIT_COMMIT="b3af679e7cf3e12d50acb83c3c591fc5db9a658d"
|
||||
DESCRIPTION="RFC 7049 - Concise Binary Object Representation"
|
||||
HOMEPAGE="https://github.com/brianolson/cbor_py
|
||||
https://pypi.org/project/cbor/"
|
||||
SRC_URI="
|
||||
https://github.com/brianolson/cbor_py/archive/${EGIT_COMMIT}.tar.gz
|
||||
-> ${P}.gh.tar.gz"
|
||||
S=${WORKDIR}/cbor_py-${EGIT_COMMIT}
|
||||
|
||||
LICENSE="Apache-2.0"
|
||||
SLOT="0"
|
||||
KEYWORDS="amd64 arm ~arm64 x86 ~amd64-linux ~x86-linux"
|
||||
|
||||
# upstream PR: https://github.com/brianolson/cbor_py/pull/19
|
||||
# upstream PR: https://github.com/brianolson/cbor_py/pull/11
|
||||
PATCHES=(
|
||||
"${FILESDIR}/cbor-1.0.0.zero-length-bytes.patch"
|
||||
"${FILESDIR}/cbor-1.0.0.Fix-broken-test_sortkeys.patch"
|
||||
"${FILESDIR}/cbor-1.0.0.Replace-deprecated-logger.warn.patch"
|
||||
)
|
||||
|
||||
python_test() {
|
||||
distutils_install_for_testing
|
||||
PYTHONPATH="${BUILD_DIR}/lib" \
|
||||
"${PYTHON:-python}" cbor/tests/test_cbor.py || die "Testsuite failed under ${EPYTHON}"
|
||||
PYTHONPATH="${BUILD_DIR}/lib" \
|
||||
"${PYTHON:-python}" cbor/tests/test_objects.py || die "Testsuite failed under ${EPYTHON}"
|
||||
PYTHONPATH="${BUILD_DIR}/lib" \
|
||||
"${PYTHON:-python}" cbor/tests/test_usage.py || die "Testsuite failed under ${EPYTHON}"
|
||||
PYTHONPATH="${BUILD_DIR}/lib" \
|
||||
"${PYTHON:-python}" cbor/tests/test_vectors.py || die "Testsuite failed under ${EPYTHON}"
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
# Copyright 1999-2020 Gentoo Authors
|
||||
# Distributed under the terms of the GNU General Public License v2
|
||||
|
||||
EAPI=7
|
||||
PYTHON_COMPAT=( python3_{6,7,8} )
|
||||
|
||||
inherit distutils-r1
|
||||
|
||||
EGIT_COMMIT="b3af679e7cf3e12d50acb83c3c591fc5db9a658d"
|
||||
DESCRIPTION="RFC 7049 - Concise Binary Object Representation"
|
||||
HOMEPAGE="https://github.com/brianolson/cbor_py
|
||||
https://pypi.org/project/cbor/"
|
||||
SRC_URI="
|
||||
https://github.com/brianolson/cbor_py/archive/${EGIT_COMMIT}.tar.gz
|
||||
-> ${P}.gh.tar.gz"
|
||||
S=${WORKDIR}/cbor_py-${EGIT_COMMIT}
|
||||
|
||||
LICENSE="Apache-2.0"
|
||||
SLOT="0"
|
||||
KEYWORDS="amd64 arm ~arm64 x86 ~amd64-linux ~x86-linux"
|
||||
|
||||
distutils_enable_tests unittest
|
||||
@@ -0,0 +1,43 @@
|
||||
From 348041c3ff7104ca5b30e518beb2d2b86bf7bd73 Mon Sep 17 00:00:00 2001
|
||||
From: Brian Dolbec <dolsen@gentoo.org>
|
||||
Date: Sun, 19 Jul 2020 16:31:42 -0700
|
||||
Subject: [PATCH] Fix issue #6 broken test_sortkeys()
|
||||
|
||||
Newer python dictionaries are keeping the order the keys were added in.
|
||||
As a result since both lists were pre-sorted and identicle so the later
|
||||
test failed to find any differences causing the failure.
|
||||
This change introduces 3 entries that are out of sorted order for both
|
||||
the obytes and xbytes lists. This ensures a valid test of sorting.
|
||||
---
|
||||
cbor/tests/test_cbor.py | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/cbor/tests/test_cbor.py b/cbor/tests/test_cbor.py
|
||||
index 78b3ddb..6ce068b 100644
|
||||
--- a/cbor/tests/test_cbor.py
|
||||
+++ b/cbor/tests/test_cbor.py
|
||||
@@ -281,6 +281,10 @@ class XTestCBOR(object):
|
||||
xbytes = []
|
||||
for n in _range(2, 27):
|
||||
ob = {u'{:02x}'.format(x):x for x in _range(n)}
|
||||
+ # ensure some "ob" have unsorted key:value entries
|
||||
+ if n in [4, 6, 9]:
|
||||
+ ob.pop('01')
|
||||
+ ob["01"] = 1
|
||||
obytes.append(self.dumps(ob, sort_keys=True))
|
||||
xbytes.append(self.dumps(ob, sort_keys=False))
|
||||
allOGood = True
|
||||
--- a/setup.py 2016-02-09 15:10:34.000000000 -0800
|
||||
+++ b/setup.py 2020-07-19 13:46:18.586936516 -0700
|
||||
@@ -75,7 +75,7 @@
|
||||
author='Brian Olson',
|
||||
author_email='bolson@bolson.org',
|
||||
url='https://bitbucket.org/bodhisnarkva/cbor',
|
||||
- packages=['cbor'],
|
||||
+ packages=['cbor', 'cbor/tests'],
|
||||
package_dir={'cbor':'cbor'},
|
||||
ext_modules=[
|
||||
Extension(
|
||||
--
|
||||
libgit2 1.0.1
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
From eea2e6c35c0962ca559a96f37ab4eada126da5de Mon Sep 17 00:00:00 2001
|
||||
From: Brian Dolbec <dolsen@gentoo.org>
|
||||
Date: Sun, 19 Jul 2020 17:56:19 -0700
|
||||
Subject: [PATCH] Replace deprecated logger.warn() with logger.warning()
|
||||
|
||||
---
|
||||
cbor/tests/test_cbor.py | 4 ++--
|
||||
cbor/tests/test_usage.py | 10 +++++-----
|
||||
cbor/tests/test_vectors.py | 2 +-
|
||||
4 files changed, 10 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/cbor/tests/test_cbor.py b/cbor/tests/test_cbor.py
|
||||
index 78b3ddb..14ddf69 100644
|
||||
--- a/cbor/tests/test_cbor.py
|
||||
+++ b/cbor/tests/test_cbor.py
|
||||
@@ -27,7 +27,7 @@ try:
|
||||
from cbor._cbor import load as cload
|
||||
except ImportError:
|
||||
# still test what we can without C fast mode
|
||||
- logger.warn('testing without C accelerated CBOR', exc_info=True)
|
||||
+ logger.warning('testing without C accelerated CBOR', exc_info=True)
|
||||
cdumps, cloads, cdump, cload = None, None, None, None
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ class TestRoot(object):
|
||||
def testable(cls):
|
||||
ok = (cls._ld[0] is not None) and (cls._ld[1] is not None) and (cls._ld[3] is not None) and (cls._ld[4] is not None)
|
||||
if not ok:
|
||||
- logger.warn('non-testable case %s skipped', cls.__name__)
|
||||
+ logger.warning('non-testable case %s skipped', cls.__name__)
|
||||
return ok
|
||||
|
||||
# Can't set class level function pointers, because then they expect a
|
||||
diff --git a/cbor/tests/test_usage.py b/cbor/tests/test_usage.py
|
||||
index d72f2e8..9d7e6a1 100644
|
||||
--- a/cbor/tests/test_usage.py
|
||||
+++ b/cbor/tests/test_usage.py
|
||||
@@ -22,7 +22,7 @@ try:
|
||||
from cbor._cbor import load as cload
|
||||
except ImportError:
|
||||
# still test what we can without C fast mode
|
||||
- logger.warn('testing without C accelerated CBOR', exc_info=True)
|
||||
+ logger.warning('testing without C accelerated CBOR', exc_info=True)
|
||||
cdumps, cloads, cdump, cload = None, None, None, None
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ class TestUsage(unittest.TestCase):
|
||||
repeatedly serialize, check that usage doesn't go up
|
||||
'''
|
||||
if cdumps is None:
|
||||
- logger.warn('no C dumps(), skipping test_dumps_usage')
|
||||
+ logger.warning('no C dumps(), skipping test_dumps_usage')
|
||||
return
|
||||
start_usage = resource.getrusage(resource.RUSAGE_SELF)
|
||||
usage_history = [start_usage]
|
||||
@@ -76,7 +76,7 @@ class TestUsage(unittest.TestCase):
|
||||
repeatedly serialize, check that usage doesn't go up
|
||||
'''
|
||||
if (cdumps is None) or (cloads is None):
|
||||
- logger.warn('no C fast CBOR, skipping test_loads_usage')
|
||||
+ logger.warning('no C fast CBOR, skipping test_loads_usage')
|
||||
return
|
||||
## Just a string passes!
|
||||
#ob = 'sntaoheusnatoheusnaotehuasnoetuhaosentuhaoesnth'
|
||||
@@ -113,7 +113,7 @@ class TestUsage(unittest.TestCase):
|
||||
it, checking usage all along the way.
|
||||
'''
|
||||
if cdump is None:
|
||||
- logger.warn('no C dump(), skipping test_tempfile')
|
||||
+ logger.warning('no C dump(), skipping test_tempfile')
|
||||
return
|
||||
with tempfile.NamedTemporaryFile() as ntf:
|
||||
# first, write a bunch to temp file
|
||||
@@ -168,7 +168,7 @@ class TestUsage(unittest.TestCase):
|
||||
def test_stringio_usage(self):
|
||||
'''serialize data to StringIO, read it back'''
|
||||
if cdump is None:
|
||||
- logger.warn('no C dump(), skipping test_tempfile')
|
||||
+ logger.warning('no C dump(), skipping test_tempfile')
|
||||
return
|
||||
|
||||
# warmup the rusage, allocate everything!
|
||||
diff --git a/cbor/tests/test_vectors.py b/cbor/tests/test_vectors.py
|
||||
index f4d8ca9..afed311 100644
|
||||
--- a/cbor/tests/test_vectors.py
|
||||
+++ b/cbor/tests/test_vectors.py
|
||||
@@ -27,7 +27,7 @@ try:
|
||||
from cbor._cbor import loads as cloads
|
||||
except ImportError:
|
||||
# still test what we can without C fast mode
|
||||
- logger.warn('testing without C accelerated CBOR', exc_info=True)
|
||||
+ logger.warning('testing without C accelerated CBOR', exc_info=True)
|
||||
#cdumps, cloads = None, None
|
||||
cloads = None
|
||||
from cbor import Tag
|
||||
--
|
||||
libgit2 1.0.1
|
||||
|
||||
10
dev-python/cbor/files/cbor-1.0.0.zero-length-bytes.patch
Normal file
10
dev-python/cbor/files/cbor-1.0.0.zero-length-bytes.patch
Normal file
@@ -0,0 +1,10 @@
|
||||
--- a/cbor/cbor.py 2020-07-19 13:24:39.497775767 -0700
|
||||
+++ b/cbor/cbor.py 2020-07-19 13:24:39.497775767 -0700
|
||||
@@ -260,6 +260,8 @@
|
||||
"""
|
||||
if data is None:
|
||||
raise ValueError("got None for buffer to decode in loads")
|
||||
+ elif data == b'':
|
||||
+ raise ValueError("got zero length string loads")
|
||||
fp = StringIO(data)
|
||||
return _loads(fp)[0]
|
||||
@@ -11,7 +11,7 @@
|
||||
<name>Brian Olson</name>
|
||||
</maintainer>
|
||||
<remote-id type="pypi">cbor</remote-id>
|
||||
<remote-id type="bitbucket">bodhisnarkva/cbor</remote-id>
|
||||
<remote-id type="github">brianolson/cbor_py</remote-id>
|
||||
</upstream>
|
||||
<longdescription>An implementation of RFC 7049 - Concise Binary Object
|
||||
Representation (CBOR). CBOR is comparable to JSON, has a superset of
|
||||
|
||||
Reference in New Issue
Block a user