add unit test for radiance buffer save
This commit is contained in:
parent
d2c4bbeda2
commit
6c1aa2b63f
@ -5,6 +5,7 @@ import unittest
|
|||||||
import math
|
import math
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
from tempfile import NamedTemporaryFile
|
||||||
|
|
||||||
#import logging
|
#import logging
|
||||||
#logging.basicConfig(level = logging.DEBUG)
|
#logging.basicConfig(level = logging.DEBUG)
|
||||||
@ -110,6 +111,20 @@ class TestForeign(unittest.TestCase):
|
|||||||
self.assertEqual(im.bands, x.bands)
|
self.assertEqual(im.bands, x.bands)
|
||||||
self.assertLessEqual((im - x).abs().max(), max_diff)
|
self.assertLessEqual((im - x).abs().max(), max_diff)
|
||||||
|
|
||||||
|
def save_buffer_tempfile(self, saver, format, im, max_diff = 0):
|
||||||
|
buf = Vips.call(saver, im)
|
||||||
|
f = NamedTemporaryFile(suffix=".hdr", delete=False)
|
||||||
|
f.write(buf)
|
||||||
|
x = Vips.Image.new_from_file(f.name)
|
||||||
|
|
||||||
|
self.assertEqual(im.width, x.width)
|
||||||
|
self.assertEqual(im.height, x.height)
|
||||||
|
self.assertEqual(im.bands, x.bands)
|
||||||
|
self.assertLessEqual((im - x).abs().max(), max_diff)
|
||||||
|
|
||||||
|
f.close()
|
||||||
|
os.unlink(f.name)
|
||||||
|
|
||||||
def test_vips(self):
|
def test_vips(self):
|
||||||
self.save_load_file("test.v", "", self.colour, 0)
|
self.save_load_file("test.v", "", self.colour, 0)
|
||||||
|
|
||||||
@ -449,6 +464,7 @@ class TestForeign(unittest.TestCase):
|
|||||||
return
|
return
|
||||||
|
|
||||||
self.save_load("%s.hdr", self.colour)
|
self.save_load("%s.hdr", self.colour)
|
||||||
|
self.save_buffer_tempfile("radsave_buffer", "%s.hdr", self.rad, max_diff = 0)
|
||||||
|
|
||||||
def test_dzsave(self):
|
def test_dzsave(self):
|
||||||
x = Vips.type_find("VipsForeign", "dzsave")
|
x = Vips.type_find("VipsForeign", "dzsave")
|
||||||
|
Loading…
Reference in New Issue
Block a user