def test_write_read_roundtrip(self, num_channels, datatype, pass_channels): expected_image, expected_channels = _MakeTestImage( num_channels, datatype) with tempfile.NamedTemporaryFile() as temp: exr.write_exr(temp.name, expected_image, expected_channels) image, channels = exr.read_exr( temp.name, expected_channels if pass_channels else None) self.assertEqual(expected_channels, channels) self.assertEqual(image.tolist(), expected_image.tolist())
def test_reading_mixed_datatypes_fails(self): with tempfile.NamedTemporaryFile() as temp: _WriteMixedDatatypesExr(temp.name) with self.assertRaisesRegexp(ValueError, 'Channels have mixed datatypes'): _, _ = exr.read_exr(temp.name)