| 1 | From db5f4ef3b469a1a412fb2f0e82679e9903452207 Mon Sep 17 00:00:00 2001
|
| 2 | From: =?UTF-8?q?Jan=20Wi=C5=9Bniewski?= <[email protected]>
|
| 3 | Date: Thu, 5 Nov 2020 16:18:52 +0100
|
| 4 | Subject: [PATCH] convert IFDRational to tuples in tests
|
| 5 |
|
| 6 | This fixes tests with Pillow version >= 7.2.0
|
| 7 | ---
|
| 8 | tests/s_test.py | 11 +++++++++++
|
| 9 | 1 file changed, 11 insertions(+)
|
| 10 |
|
| 11 | diff --git a/tests/s_test.py b/tests/s_test.py
|
| 12 | index 5d105de..382d1ef 100644
|
| 13 | |
| 14 | |
| 15 | @@ -9,6 +9,7 @@ import sys
|
| 16 | import time
|
| 17 | import unittest
|
| 18 |
|
| 19 | +import PIL
|
| 20 | from PIL import Image
|
| 21 | import piexif
|
| 22 | from piexif import _common, ImageIFD, ExifIFD, GPSIFD, TAGS, InvalidImageDataError
|
| 23 | @@ -580,6 +581,16 @@ class ExifTests(unittest.TestCase):
|
| 24 | # test utility methods----------------------------------------------
|
| 25 |
|
| 26 | def _compare_value(self, v1, v2):
|
| 27 | + if isinstance(v2, PIL.TiffImagePlugin.IFDRational):
|
| 28 | + v2 = (v2.numerator, v2.denominator)
|
| 29 | + if isinstance(v2, tuple):
|
| 30 | + converted_v2 = []
|
| 31 | + for el in v2:
|
| 32 | + if isinstance(el, PIL.TiffImagePlugin.IFDRational):
|
| 33 | + converted_v2.append((el.numerator, el.denominator))
|
| 34 | + else:
|
| 35 | + converted_v2.append(el)
|
| 36 | + v2 = tuple(converted_v2)
|
| 37 | if type(v1) != type(v2):
|
| 38 | if isinstance(v1, tuple):
|
| 39 | self.assertEqual(pack_byte(*v1), v2)
|
| 40 | --
|
| 41 | 2.51.2
|
| 42 |
|