mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-14 05:36:48 +03:00
4de5477b61
With the introduction and use of pytest, it is simple and easy to execute specific tests in isolation through documented command line arguments. Either by specifying the module path or through the `-k EXPRESSION` argument. There is no longer any need to provide the boilerplate: if __name__ == '__main__': unittest.main() To every test file. It is simply noise. The pattern remains in test files that aren't named with `test_*` as those files are not discovered and executed by pytest by default.
54 lines
1.6 KiB
Python
54 lines
1.6 KiB
Python
from .helper import PillowTestCase, hopper
|
|
|
|
from PIL import Image
|
|
from PIL import WmfImagePlugin
|
|
|
|
|
|
class TestFileWmf(PillowTestCase):
|
|
|
|
def test_load_raw(self):
|
|
|
|
# Test basic EMF open and rendering
|
|
im = Image.open('Tests/images/drawing.emf')
|
|
if hasattr(Image.core, "drawwmf"):
|
|
# Currently, support for WMF/EMF is Windows-only
|
|
im.load()
|
|
# Compare to reference rendering
|
|
imref = Image.open('Tests/images/drawing_emf_ref.png')
|
|
imref.load()
|
|
self.assert_image_similar(im, imref, 0)
|
|
|
|
# Test basic WMF open and rendering
|
|
im = Image.open('Tests/images/drawing.wmf')
|
|
if hasattr(Image.core, "drawwmf"):
|
|
# Currently, support for WMF/EMF is Windows-only
|
|
im.load()
|
|
# Compare to reference rendering
|
|
imref = Image.open('Tests/images/drawing_wmf_ref.png')
|
|
imref.load()
|
|
self.assert_image_similar(im, imref, 2.0)
|
|
|
|
def test_register_handler(self):
|
|
class TestHandler:
|
|
methodCalled = False
|
|
|
|
def save(self, im, fp, filename):
|
|
self.methodCalled = True
|
|
handler = TestHandler()
|
|
WmfImagePlugin.register_handler(handler)
|
|
|
|
im = hopper()
|
|
tmpfile = self.tempfile("temp.wmf")
|
|
im.save(tmpfile)
|
|
self.assertTrue(handler.methodCalled)
|
|
|
|
# Restore the state before this test
|
|
WmfImagePlugin.register_handler(None)
|
|
|
|
def test_save(self):
|
|
im = hopper()
|
|
|
|
for ext in [".wmf", ".emf"]:
|
|
tmpfile = self.tempfile("temp"+ext)
|
|
self.assertRaises(IOError, im.save, tmpfile)
|