Skip to content

Commit

Permalink
Merge pull request #3516 from radarhere/eps
Browse files Browse the repository at this point in the history
Allow EPS tests that do not require Ghostscript
  • Loading branch information
hugovk committed Dec 30, 2018
2 parents 332f634 + 0c0f769 commit 37d61f1
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions Tests/test_file_eps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from PIL import Image, EpsImagePlugin
import io

HAS_GHOSTSCRIPT = EpsImagePlugin.has_ghostscript()

# Our two EPS test files (they are identical except for their bounding boxes)
file1 = "Tests/images/zero_bb.eps"
file2 = "Tests/images/non_zero_bb.eps"
Expand All @@ -20,10 +22,7 @@

class TestFileEps(PillowTestCase):

def setUp(self):
if not EpsImagePlugin.has_ghostscript():
self.skipTest("Ghostscript not available")

@unittest.skipUnless(HAS_GHOSTSCRIPT, "Ghostscript not available")
def test_sanity(self):
# Regular scale
image1 = Image.open(file1)
Expand Down Expand Up @@ -57,6 +56,7 @@ def test_invalid_file(self):
self.assertRaises(SyntaxError,
EpsImagePlugin.EpsImageFile, invalid_file)

@unittest.skipUnless(HAS_GHOSTSCRIPT, "Ghostscript not available")
def test_cmyk(self):
cmyk_image = Image.open("Tests/images/pil_sample_cmyk.eps")

Expand All @@ -71,6 +71,7 @@ def test_cmyk(self):
target = Image.open('Tests/images/pil_sample_rgb.jpg')
self.assert_image_similar(cmyk_image, target, 10)

@unittest.skipUnless(HAS_GHOSTSCRIPT, "Ghostscript not available")
def test_showpage(self):
# See https://github.com/python-pillow/Pillow/issues/2615
plot_image = Image.open("Tests/images/reqd_showpage.eps")
Expand All @@ -81,18 +82,21 @@ def test_showpage(self):
# fonts could be slightly different
self.assert_image_similar(plot_image, target, 6)

@unittest.skipUnless(HAS_GHOSTSCRIPT, "Ghostscript not available")
def test_file_object(self):
# issue 479
image1 = Image.open(file1)
with open(self.tempfile('temp_file.eps'), 'wb') as fh:
image1.save(fh, 'EPS')

@unittest.skipUnless(HAS_GHOSTSCRIPT, "Ghostscript not available")
def test_iobase_object(self):
# issue 479
image1 = Image.open(file1)
with io.open(self.tempfile('temp_iobase.eps'), 'wb') as fh:
image1.save(fh, 'EPS')

@unittest.skipUnless(HAS_GHOSTSCRIPT, "Ghostscript not available")
def test_bytesio_object(self):
with open(file1, 'rb') as f:
img_bytes = io.BytesIO(f.read())
Expand All @@ -109,6 +113,7 @@ def test_image_mode_not_supported(self):
tmpfile = self.tempfile('temp.eps')
self.assertRaises(ValueError, im.save, tmpfile)

@unittest.skipUnless(HAS_GHOSTSCRIPT, "Ghostscript not available")
def test_render_scale1(self):
# We need png support for these render test
codecs = dir(Image.core)
Expand All @@ -129,6 +134,7 @@ def test_render_scale1(self):
image2_scale1_compare.load()
self.assert_image_similar(image2_scale1, image2_scale1_compare, 10)

@unittest.skipUnless(HAS_GHOSTSCRIPT, "Ghostscript not available")
def test_render_scale2(self):
# We need png support for these render test
codecs = dir(Image.core)
Expand All @@ -149,6 +155,7 @@ def test_render_scale2(self):
image2_scale2_compare.load()
self.assert_image_similar(image2_scale2, image2_scale2_compare, 10)

@unittest.skipUnless(HAS_GHOSTSCRIPT, "Ghostscript not available")
def test_resize(self):
# Arrange
image1 = Image.open(file1)
Expand All @@ -166,6 +173,7 @@ def test_resize(self):
self.assertEqual(image2.size, new_size)
self.assertEqual(image3.size, new_size)

@unittest.skipUnless(HAS_GHOSTSCRIPT, "Ghostscript not available")
def test_thumbnail(self):
# Issue #619
# Arrange
Expand Down Expand Up @@ -233,6 +241,7 @@ def test_open_eps(self):
img = Image.open(filename)
self.assertEqual(img.mode, "RGB")

@unittest.skipUnless(HAS_GHOSTSCRIPT, "Ghostscript not available")
def test_emptyline(self):
# Test file includes an empty line in the header data
emptyline_file = "Tests/images/zero_bb_emptyline.eps"
Expand Down

0 comments on commit 37d61f1

Please sign in to comment.