10000 gh-119791: Fix new Tkinter tests for wantobjects=0 by serhiy-storchaka · Pull Request #119792 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-119791: Fix new Tkinter tests for wantobjects=0 #119792

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
gh-119791: Fix new Tkinter tests for wantobjects=0
PhotoImage.get() retruns a string instead of a 3-tuple of integers
in this case.
  • Loading branch information
serhiy-storchaka committed May 30, 2024
commit 4823766f8166172fa9051a8eaa5bcf016dfede19
13 changes: 10 additions & 3 deletions Lib/test/test_tkinter/test_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,13 +581,15 @@ def test_write(self):
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):
Expand All @@ -597,7 +599,10 @@ def test_data(self):
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,
Expand All @@ -622,13 +627,15 @@ def test_data(self):
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)


Expand Down
0