Pillow/Tests/test_file_mcidas.py

29 lines
959 B
Python
Raw Normal View History

2017-05-28 16:11:16 +03:00
from PIL import Image, McIdasImagePlugin
2015-07-03 08:03:25 +03:00
from .helper import PillowTestCase
2015-07-03 08:03:25 +03:00
class TestFileMcIdas(PillowTestCase):
def test_invalid_file(self):
2015-07-03 09:22:56 +03:00
invalid_file = "Tests/images/flower.jpg"
2019-06-13 18:54:11 +03:00
self.assertRaises(SyntaxError, McIdasImagePlugin.McIdasImageFile, invalid_file)
2015-07-03 08:03:25 +03:00
2017-05-28 16:11:16 +03:00
def test_valid_file(self):
# Arrange
# https://ghrc.nsstc.nasa.gov/hydro/details/cmx3g8
# https://ghrc.nsstc.nasa.gov/pub/fieldCampaigns/camex3/cmx3g8/browse/
test_file = "Tests/images/cmx3g8_wv_1998.260_0745_mcidas.ara"
saved_file = "Tests/images/cmx3g8_wv_1998.260_0745_mcidas.png"
# Act
2019-11-25 23:03:23 +03:00
with Image.open(test_file) as im:
im.load()
2017-05-28 16:11:16 +03:00
2019-11-25 23:03:23 +03:00
# Assert
self.assertEqual(im.format, "MCIDAS")
self.assertEqual(im.mode, "I")
self.assertEqual(im.size, (1800, 400))
with Image.open(saved_file) as im2:
self.assert_image_equal(im, im2)