From 65c7875ff7c65b10b71455c5e153f58c598241c8 Mon Sep 17 00:00:00 2001 From: Daniel Plakhotich Date: Thu, 14 Jun 2018 12:20:04 +0300 Subject: [PATCH] TestFilePng: Fix test_save_l_transparency() It now really tests the file after saving. --- Tests/test_file_png.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/Tests/test_file_png.py b/Tests/test_file_png.py index c78351464..bc2b557d2 100644 --- a/Tests/test_file_png.py +++ b/Tests/test_file_png.py @@ -292,15 +292,29 @@ class TestFilePng(PillowTestCase): self.assertEqual(im.getcolors(), [(100, (0, 0, 0, 0))]) def test_save_l_transparency(self): + # There are 559 transparent pixels in l_trns.png. + num_transparent = 559 + in_file = "Tests/images/l_trns.png" im = Image.open(in_file) + self.assertEqual(im.mode, "L") + self.assertEqual(im.info["transparency"], 255) + + im_rgba = im.convert('RGBA') + self.assertEqual( + im_rgba.getchannel("A").getcolors()[0][0], num_transparent) test_file = self.tempfile("temp.png") im.save(test_file) - # There are 559 transparent pixels. - im = im.convert('RGBA') - self.assertEqual(im.getchannel('A').getcolors()[0][0], 559) + test_im = Image.open(test_file) + self.assertEqual(test_im.mode, "L") + self.assertEqual(test_im.info["transparency"], 255) + self.assert_image_equal(im, test_im) + + test_im_rgba = test_im.convert('RGBA') + self.assertEqual( + test_im_rgba.getchannel('A').getcolors()[0][0], num_transparent) def test_save_rgb_single_transparency(self): in_file = "Tests/images/caption_6_33_22.png"