test failing update

This commit is contained in:
wiredfool 2015-09-11 14:24:35 -07:00
parent 5f9fff0215
commit 426c9d8fc2

View File

@ -34,64 +34,59 @@ class TestFileTiffMetadata(PillowTestCase):
img.save(f, tiffinfo=info) img.save(f, tiffinfo=info)
for legacy_api in [False, True]: loaded = Image.open(f)
loaded = Image.open(f)
loaded.tag.legacy_api = legacy_api
self.assertEqual(loaded.tag[50838], self.assertEqual(loaded.tag[50838], (len(basetextdata + " ?"),))
(len(basetextdata + " ?"),) if legacy_api else len(basetextdata + " ?")) self.assertEqual(loaded.tag_v2[50838], len(basetextdata + " ?"))
self.assertEqual(loaded.tag[50839], basetextdata + " ?")
loaded_float = loaded.tag[tag_ids['RollAngle']] self.assertEqual(loaded.tag[50839], basetextdata + " ?")
if legacy_api: self.assertEqual(loaded.tag_v2[50839], basetextdata + " ?")
loaded_float = loaded_float[0]
self.assertAlmostEqual(loaded_float, floatdata, places=5)
loaded_double = loaded.tag[tag_ids['YawAngle']] loaded_float = loaded.tag[tag_ids['RollAngle']][0]
if legacy_api: self.assertAlmostEqual(loaded_float, floatdata, places=5)
loaded_double = loaded_double[0] loaded_double = loaded.tag[tag_ids['YawAngle']][0]
self.assertAlmostEqual(loaded_double, doubledata) self.assertAlmostEqual(loaded_double, doubledata)
def test_read_metadata(self): def test_read_metadata(self):
for legacy_api in [False, True]: img = Image.open('Tests/images/hopper_g4.tif')
img = Image.open('Tests/images/hopper_g4.tif')
img.tag.legacy_api = legacy_api
known = {'YResolution': ((4294967295, 113653537),), self.assertEqual({'YResolution': 4294967295 / 113653537,
'PlanarConfiguration': (1,), 'PlanarConfiguration': 1,
'BitsPerSample': (1,), 'BitsPerSample': (1,),
'ImageLength': (128,), 'ImageLength': 128,
'Compression': (4,), 'Compression': 4,
'FillOrder': (1,), 'FillOrder': 1,
'RowsPerStrip': (128,), 'RowsPerStrip': 128,
'ResolutionUnit': (3,), 'ResolutionUnit': 3,
'PhotometricInterpretation': (0,), 'PhotometricInterpretation': 0,
'PageNumber': (0, 1), 'PageNumber': (0, 1),
'XResolution': ((4294967295, 113653537),), 'XResolution': 4294967295 / 113653537,
'ImageWidth': (128,), 'ImageWidth': 128,
'Orientation': (1,), 'Orientation': 1,
'StripByteCounts': (1968,), 'StripByteCounts': (1968,),
'SamplesPerPixel': (1,), 'SamplesPerPixel': 1,
'StripOffsets': (8,) 'StripOffsets': (8,)
} if legacy_api else { }, img.tag_v2.named())
'YResolution': 4294967295 / 113653537,
'PlanarConfiguration': 1,
'BitsPerSample': (1,),
'ImageLength': 128,
'Compression': 4,
'FillOrder': 1,
'RowsPerStrip': 128,
'ResolutionUnit': 3,
'PhotometricInterpretation': 0,
'PageNumber': (0, 1),
'XResolution': 4294967295 / 113653537,
'ImageWidth': 128,
'Orientation': 1,
'StripByteCounts': (1968,),
'SamplesPerPixel': 1,
'StripOffsets': (8,)
}
self.assertEqual(known, img.tag.named()) self.assertEqual({'YResolution': ((4294967295, 113653537),),
'PlanarConfiguration': (1,),
'BitsPerSample': (1,),
'ImageLength': (128,),
'Compression': (4,),
'FillOrder': (1,),
'RowsPerStrip': (128,),
'ResolutionUnit': (3,),
'PhotometricInterpretation': (0,),
'PageNumber': (0, 1),
'XResolution': ((4294967295, 113653537),),
'ImageWidth': (128,),
'Orientation': (1,),
'StripByteCounts': (1968,),
'SamplesPerPixel': (1,),
'StripOffsets': (8,)
}, img.tag.named())
def test_write_metadata(self): def test_write_metadata(self):
""" Test metadata writing through the python code """ """ Test metadata writing through the python code """