def test_bytesio(self): bio = io.BytesIO() # Save from dot direct dot.save(self.cube1, self.temp_filename1) # Call save on iris iris.save(self.cube1, bio, iris.io.find_saver(self.ext)) with open(self.temp_filename1) as infile: data = infile.read() # Compare files self.assertEquals(data, bio.getvalue(), "Mismatch in data when comparing iris bytesio save and dot.save.")
def test_cstringio(self): string_io = cStringIO.StringIO() # Save from dot direct dot.save(self.cube1, self.temp_filename1) # Call save on iris iris.save(self.cube1, string_io, iris.io.find_saver(self.ext)) with open(self.temp_filename1) as infile: data = infile.read() # Compare files self.assertEquals(data, string_io.getvalue(), "Mismatch in data when comparing iris cstringio save and dot.save.")
def _dot_save(cube, target): # A simple wrapper for `iris.fileformats.dot.save` which allows the # saver to be registered without triggering the import of # `iris.fileformats.dot`. from iris.fileformats.dot import save return save(cube, target)
def test_bytesio(self): bio = io.BytesIO() # Save from dot direct dot.save(self.cube1, self.temp_filename1) # Call save on iris iris.save(self.cube1, bio, iris.io.find_saver(self.ext)) with open(self.temp_filename1) as infile: data = infile.read() # Compare files self.assertEqual( data, bio.getvalue(), 'Mismatch in data when comparing iris bytesio save ' 'and dot.save.')