summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2024-05-30 19:16:57 (GMT)
committerGitHub <noreply@github.com>2024-05-30 19:16:57 (GMT)
commitd6bede815dd88adb9a89eda15c01573fd03af080 (patch)
tree8591078f6d63f74d63575f97c216d3af85eb12b5
parent608cfb8b416d0c2f55efb94f57efcc86d74dbf80 (diff)
downloadcpython-d6bede815dd88adb9a89eda15c01573fd03af080.zip
cpython-d6bede815dd88adb9a89eda15c01573fd03af080.tar.gz
cpython-d6bede815dd88adb9a89eda15c01573fd03af080.tar.bz2
[3.13] gh-119791: Fix new Tkinter tests for wantobjects=0 (GH-119792) (GH-119794)
PhotoImage.get() retruns a string instead of a 3-tuple of integers in this case. (cherry picked from commit e875c2d752fed0a8d16958dc7b331e66a2476247) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
-rw-r--r--Lib/test/test_tkinter/test_images.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/Lib/test/test_tkinter/test_images.py b/Lib/test/test_tkinter/test_images.py
index b8e549e..38371fe 100644
--- a/Lib/test/test_tkinter/test_images.py
+++ b/Lib/test/test_tkinter/test_images.py
@@ -581,13 +581,15 @@ class PhotoImageTest(AbstractTkTest, unittest.TestCase):
image.write(filename, background='#ff0000')
image4 = tkinter.PhotoImage('::img::test4', master=self.root,
format='ppm', file=filename)
- self.assertEqual(image4.get(0, 0), (255, 0, 0))
+ self.assertEqual(image4.get(0, 0), (255, 0, 0) if self.wantobjects else '255 0 0')
self.assertEqual(image4.get(4, 6), image.get(4, 6))
image.write(filename, grayscale=True)
image5 = tkinter.PhotoImage('::img::test5', master=self.root,
format='ppm', file=filename)
c = image5.get(4, 6)
+ if not self.wantobjects:
+ c = c.split()
self.assertTrue(c[0] == c[1] == c[2], c)
def test_data(self):
@@ -597,7 +599,10 @@ class PhotoImageTest(AbstractTkTest, unittest.TestCase):
self.assertIsInstance(data, tuple)
for row in data:
self.assertIsInstance(row, str)
- self.assertEqual(data[6].split()[4], '#%02x%02x%02x' % image.get(4, 6))
+ c = image.get(4, 6)
+ if not self.wantobjects:
+ c = tuple(map(int, c.split()))
+ self.assertEqual(data[6].split()[4], '#%02x%02x%02x' % c)
data = image.data('ppm')
image2 = tkinter.PhotoImage('::img::test2', master=self.root,
@@ -622,13 +627,15 @@ class PhotoImageTest(AbstractTkTest, unittest.TestCase):
data = image.data('ppm', background='#ff0000')
image4 = tkinter.PhotoImage('::img::test4', master=self.root,
format='ppm', data=data)
- self.assertEqual(image4.get(0, 0), (255, 0, 0))
+ self.assertEqual(image4.get(0, 0), (255, 0, 0) if self.wantobjects else '255 0 0')
self.assertEqual(image4.get(4, 6), image.get(4, 6))
data = image.data('ppm', grayscale=True)
image5 = tkinter.PhotoImage('::img::test5', master=self.root,
format='ppm', data=data)
c = image5.get(4, 6)
+ if not self.wantobjects:
+ c = c.split()
self.assertTrue(c[0] == c[1] == c[2], c)