From dbf0ee3631c51aa376693311475d1425b1fbb9fa Mon Sep 17 00:00:00 2001 From: hugovk Date: Tue, 26 Aug 2014 12:04:04 +0300 Subject: [PATCH] Add (failing) test for GIMP 1.3 gradient files and .ggr by me --- Tests/images/gimp_gradient_with_name.ggr | 7 +++++++ Tests/test_file_gimpgradient.py | 20 +++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 Tests/images/gimp_gradient_with_name.ggr diff --git a/Tests/images/gimp_gradient_with_name.ggr b/Tests/images/gimp_gradient_with_name.ggr new file mode 100644 index 000000000..ab1c1d734 --- /dev/null +++ b/Tests/images/gimp_gradient_with_name.ggr @@ -0,0 +1,7 @@ +GIMP Gradient +Name: A GIMP 1.3 gradient file +4 +0.000000 0.351923 0.534893 1.000000 1.000000 1.000000 0.910000 0.730303 0.510606 1.000000 0.480000 1 0 +0.501504 0.611002 0.637730 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 1.000000 1 0 +0.931891 0.951264 1.000000 0.531255 0.316078 1.031173 1.000000 0.000000 0.000000 0.000000 1.000000 0 0 +0.810551 0.881217 0.921883 0.717576 0.441331 0.081217 1.000000 0.751576 0.410331 0.081217 1.000000 0 0 \ No newline at end of file diff --git a/Tests/test_file_gimpgradient.py b/Tests/test_file_gimpgradient.py index e024c0903..ef941c0eb 100644 --- a/Tests/test_file_gimpgradient.py +++ b/Tests/test_file_gimpgradient.py @@ -2,8 +2,6 @@ from helper import unittest, PillowTestCase from PIL import GimpGradientFile -TEST_FILE = "Tests/images/gimp_gradient.ggr" - class TestImage(PillowTestCase): @@ -87,9 +85,25 @@ class TestImage(PillowTestCase): def test_load_via_imagepalette(self): # Arrange from PIL import ImagePalette + test_file = "Tests/images/gimp_gradient.ggr" # Act - palette = ImagePalette.load(TEST_FILE) + palette = ImagePalette.load(test_file) + + # Assert + # load returns raw palette information + self.assertEqual(len(palette[0]), 1024) + self.assertEqual(palette[1], "RGBA") + + + def test_load_1_3_via_imagepalette(self): + # Arrange + from PIL import ImagePalette + # GIMP 1.3 gradient files contain a name field + test_file = "Tests/images/gimp_gradient_with_name.ggr" + + # Act + palette = ImagePalette.load(test_file) # Assert # load returns raw palette information