~ruther/guix-local

ref: f3d2705f64ac3ef2dcdcd0d48eed413fb1fdab40 guix-local/gnu/packages/patches/python-piexif-fix-tests-with-pillow-7.2.patch -rw-r--r-- 1.4 KiB
f3d2705f — Cayetano Santos gnu: ieee-p1076: Move to hdl. 30 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
From db5f4ef3b469a1a412fb2f0e82679e9903452207 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Wi=C5=9Bniewski?= <vuko@vuko.pl>
Date: Thu, 5 Nov 2020 16:18:52 +0100
Subject: [PATCH] convert IFDRational to tuples in tests

This fixes tests with Pillow version >= 7.2.0
---
 tests/s_test.py | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/tests/s_test.py b/tests/s_test.py
index 5d105de..382d1ef 100644
--- a/tests/s_test.py
+++ b/tests/s_test.py
@@ -9,6 +9,7 @@ import sys
 import time
 import unittest
 
+import PIL
 from PIL import Image
 import piexif
 from piexif import _common, ImageIFD, ExifIFD, GPSIFD, TAGS, InvalidImageDataError
@@ -580,6 +581,16 @@ class ExifTests(unittest.TestCase):
 # test utility methods----------------------------------------------
 
     def _compare_value(self, v1, v2):
+        if isinstance(v2, PIL.TiffImagePlugin.IFDRational):
+            v2 = (v2.numerator, v2.denominator)
+        if isinstance(v2, tuple):
+            converted_v2 = []
+            for el in v2:
+                if isinstance(el, PIL.TiffImagePlugin.IFDRational):
+                    converted_v2.append((el.numerator, el.denominator))
+                else:
+                    converted_v2.append(el)
+            v2 = tuple(converted_v2)
         if type(v1) != type(v2):
             if isinstance(v1, tuple):
                 self.assertEqual(pack_byte(*v1), v2)
-- 
2.51.2