public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] repo/gentoo:master commit in: dev-python/u-msgpack/, dev-python/u-msgpack/files/
@ 2017-09-22 19:40 Sergei Trofimovich
  0 siblings, 0 replies; only message in thread
From: Sergei Trofimovich @ 2017-09-22 19:40 UTC (permalink / raw
  To: gentoo-commits

commit:     43dec825bf59fb64ce7f835b57d5c32c2dda4a71
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Fri Sep 22 11:17:50 2017 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Fri Sep 22 19:40:08 2017 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=43dec825

dev-python/u-msgpack: tweak tests for big-endian platforms

Noticed test failures on powerpc and powerpc64.

Sent upstream as: https://github.com/vsergeev/u-msgpack-python/pull/31

Package-Manager: Portage-2.3.10, Repoman-2.3.3

 .../files/u-msgpack-2.4.1-little-endian.patch      | 60 ++++++++++++++++++++++
 dev-python/u-msgpack/u-msgpack-2.4.1.ebuild        |  2 +
 2 files changed, 62 insertions(+)

diff --git a/dev-python/u-msgpack/files/u-msgpack-2.4.1-little-endian.patch b/dev-python/u-msgpack/files/u-msgpack-2.4.1-little-endian.patch
new file mode 100644
index 00000000000..c04aca3a357
--- /dev/null
+++ b/dev-python/u-msgpack/files/u-msgpack-2.4.1-little-endian.patch
@@ -0,0 +1,60 @@
+https://github.com/vsergeev/u-msgpack-python/pull/31
+
+From 003289878812c63ef046dc7090953b8dde784f8c Mon Sep 17 00:00:00 2001
+From: Sergei Trofimovich <slyfox@gentoo.org>
+Date: Fri, 22 Sep 2017 12:09:30 +0100
+Subject: [PATCH] test_umsgpack.py: fix test on big-endian platforms
+
+On powerpc and powerpc64 one test fails as:
+
+```
+  $ py.test -v
+  ...
+  test_umsgpack.py::TestUmsgpack::test_pack_ext_handler FAILED
+  test_umsgpack.py::TestUmsgpack::test_unpack_ext_handler FAILED
+  ...
+
+  self = <test_umsgpack.TestUmsgpack testMethod=test_pack_ext_handler>
+
+    def test_pack_ext_handler(self):
+        for (name, obj, data) in ext_handlers_test_vectors:
+            obj_repr = repr(obj)
+            print("\tTesting %s: object %s" %
+                  (name, obj_repr if len(obj_repr) < 24 else obj_repr[0:24] + "..."))
+            packed = umsgpack.packb(obj, ext_handlers=ext_handlers)
+  >           self.assertEqual(packed, data)
+  E           AssertionError: b'\xd7 ?\x80\x00\x00@\x00\x00\x00' != b'\xd7 \x00\x00\x80?\x00\x00\x00@'
+
+  test_umsgpack.py:484: AssertionError
+```
+
+The problem here is in 'struct.pack' output:
+it uses native endianness format but test hardcodes little-endian output.
+
+The change forces 'struct.pack' into little-endian format.
+That way all tests pass:.
+
+Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
+---
+ test_umsgpack.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/test_umsgpack.py b/test_umsgpack.py
+index a25b5b8..e500276 100644
+--- a/test_umsgpack.py
++++ b/test_umsgpack.py
+@@ -297,9 +297,9 @@ float_precision_test_vectors = [
+ CustomType = namedtuple('CustomType', ['x', 'y', 'z'])
+ 
+ ext_handlers = {
+-    complex: lambda obj: umsgpack.Ext(0x20, struct.pack("ff", obj.real, obj.imag)),
++    complex: lambda obj: umsgpack.Ext(0x20, struct.pack("<ff", obj.real, obj.imag)),
+     CustomType: lambda obj: umsgpack.Ext(0x30, umsgpack.packb(list(obj))),
+-    0x20: lambda ext: complex(*struct.unpack("ff", ext.data)),
++    0x20: lambda ext: complex(*struct.unpack("<ff", ext.data)),
+     0x30: lambda ext: CustomType(*umsgpack.unpackb(ext.data)),
+ }
+ 
+-- 
+2.14.1
+

diff --git a/dev-python/u-msgpack/u-msgpack-2.4.1.ebuild b/dev-python/u-msgpack/u-msgpack-2.4.1.ebuild
index 7f036ea1609..7a4bd01ffa3 100644
--- a/dev-python/u-msgpack/u-msgpack-2.4.1.ebuild
+++ b/dev-python/u-msgpack/u-msgpack-2.4.1.ebuild
@@ -24,6 +24,8 @@ DEPEND="${RDEPEND}
 
 S=${WORKDIR}/${MY_P}
 
+PATCHES=("${FILESDIR}"/${P}-little-endian.patch)
+
 python_test() {
 	py.test -v || die "Tests fail with ${EPYTHON}"
 }


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-09-22 19:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-22 19:40 [gentoo-commits] repo/gentoo:master commit in: dev-python/u-msgpack/, dev-python/u-msgpack/files/ Sergei Trofimovich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox