refactored, skipping tests not to be run on openjpeg 1.3
This commit is contained in:
parent
036b14cc2b
commit
117b7d1bbe
1 changed files with 43 additions and 34 deletions
|
|
@ -24,6 +24,7 @@ from .fixtures import OPJ_DATA_ROOT, opj_data_file, read_image
|
|||
from .fixtures import NO_READ_BACKEND, NO_READ_BACKEND_MSG
|
||||
from .fixtures import NO_SKIMAGE_FREEIMAGE_SUPPORT
|
||||
from .fixtures import WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG
|
||||
from . import fixtures
|
||||
|
||||
from glymur import Jp2k
|
||||
import glymur
|
||||
|
|
@ -31,7 +32,7 @@ import glymur
|
|||
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_OPJ_DATA_ROOT environment variable not set")
|
||||
class TestSuiteNegative(unittest.TestCase):
|
||||
class TestSuiteNegativeRead(unittest.TestCase):
|
||||
"""Test suite for certain negative tests from openjpeg suite."""
|
||||
|
||||
def setUp(self):
|
||||
|
|
@ -41,33 +42,6 @@ class TestSuiteNegative(unittest.TestCase):
|
|||
def tearDown(self):
|
||||
pass
|
||||
|
||||
|
||||
@unittest.skipIf(NO_SKIMAGE_FREEIMAGE_SUPPORT,
|
||||
"Cannot read input image without scikit-image/freeimage")
|
||||
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||
def test_cinema2K_bad_frame_rate(self):
|
||||
"""Cinema2k frame rate must be either 24 or 48."""
|
||||
relfile = 'input/nonregression/X_5_2K_24_235_CBR_STEM24_000.tif'
|
||||
infile = opj_data_file(relfile)
|
||||
data = skimage.io.imread(infile)
|
||||
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
|
||||
j = Jp2k(tfile.name, 'wb')
|
||||
with self.assertRaises(IOError):
|
||||
j.write(data, cinema2k=36)
|
||||
|
||||
|
||||
@unittest.skipIf(NO_READ_BACKEND, NO_READ_BACKEND_MSG)
|
||||
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||
def test_psnr_with_cratios(self):
|
||||
"""Using psnr with cratios options is not allowed."""
|
||||
# Not an OpenJPEG test, but close.
|
||||
infile = opj_data_file('input/nonregression/Bretagne1.ppm')
|
||||
data = read_image(infile)
|
||||
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
|
||||
j = Jp2k(tfile.name, 'wb')
|
||||
with self.assertRaises(IOError):
|
||||
j.write(data, psnr=[30, 35, 40], cratios=[2, 3, 4])
|
||||
|
||||
def test_nr_marker_not_compliant(self):
|
||||
"""non-compliant marker, should still be able to read"""
|
||||
relpath = 'input/nonregression/MarkerIsNotCompliant.j2k'
|
||||
|
|
@ -98,7 +72,47 @@ class TestSuiteNegative(unittest.TestCase):
|
|||
jp2k.get_codestream(header_only=False)
|
||||
self.assertTrue(True)
|
||||
|
||||
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||
|
||||
@unittest.skipIf(re.match("1.5|2", glymur.version.openjpeg_version) is None,
|
||||
"Must have openjpeg 1.5 or higher to run")
|
||||
@unittest.skipIf(os.name == "nt", fixtures.WINDOWS_TMP_FILE_MSG)
|
||||
@unittest.skipIf(OPJ_DATA_ROOT is None,
|
||||
"OPJ_OPJ_DATA_ROOT environment variable not set")
|
||||
class TestSuiteNegativeWrite(unittest.TestCase):
|
||||
"""Test suite for certain negative tests from openjpeg suite."""
|
||||
|
||||
def setUp(self):
|
||||
self.jp2file = glymur.data.nemo()
|
||||
self.j2kfile = glymur.data.goodstuff()
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
|
||||
@unittest.skipIf(NO_SKIMAGE_FREEIMAGE_SUPPORT,
|
||||
"Cannot read input image without scikit-image/freeimage")
|
||||
def test_cinema2K_bad_frame_rate(self):
|
||||
"""Cinema2k frame rate must be either 24 or 48."""
|
||||
relfile = 'input/nonregression/X_5_2K_24_235_CBR_STEM24_000.tif'
|
||||
infile = opj_data_file(relfile)
|
||||
data = skimage.io.imread(infile)
|
||||
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
|
||||
j = Jp2k(tfile.name, 'wb')
|
||||
with self.assertRaises(IOError):
|
||||
j.write(data, cinema2k=36)
|
||||
|
||||
|
||||
@unittest.skipIf(NO_READ_BACKEND, NO_READ_BACKEND_MSG)
|
||||
def test_psnr_with_cratios(self):
|
||||
"""Using psnr with cratios options is not allowed."""
|
||||
# Not an OpenJPEG test, but close.
|
||||
infile = opj_data_file('input/nonregression/Bretagne1.ppm')
|
||||
data = read_image(infile)
|
||||
with tempfile.NamedTemporaryFile(suffix='.j2k') as tfile:
|
||||
j = Jp2k(tfile.name, 'wb')
|
||||
with self.assertRaises(IOError):
|
||||
j.write(data, psnr=[30, 35, 40], cratios=[2, 3, 4])
|
||||
|
||||
def test_code_block_dimensions(self):
|
||||
"""don't allow extreme codeblock sizes"""
|
||||
# opj_compress doesn't allow the dimensions of a codeblock
|
||||
|
|
@ -117,7 +131,6 @@ class TestSuiteNegative(unittest.TestCase):
|
|||
with self.assertRaises(IOError):
|
||||
j.write(data, cbsize=(2, 2048))
|
||||
|
||||
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||
def test_precinct_size_not_p2(self):
|
||||
"""precinct sizes should be powers of two."""
|
||||
ifile = Jp2k(self.j2kfile)
|
||||
|
|
@ -127,7 +140,6 @@ class TestSuiteNegative(unittest.TestCase):
|
|||
with self.assertRaises(IOError):
|
||||
ofile.write(data, psizes=[(13, 13)])
|
||||
|
||||
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||
def test_cblk_size_not_power_of_two(self):
|
||||
"""code block sizes should be powers of two."""
|
||||
ifile = Jp2k(self.j2kfile)
|
||||
|
|
@ -137,7 +149,6 @@ class TestSuiteNegative(unittest.TestCase):
|
|||
with self.assertRaises(IOError):
|
||||
ofile.write(data, cbsize=(13, 12))
|
||||
|
||||
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
|
||||
def test_cblk_size_precinct_size(self):
|
||||
"""code block sizes should never exceed half that of precinct size."""
|
||||
ifile = Jp2k(self.j2kfile)
|
||||
|
|
@ -149,5 +160,3 @@ class TestSuiteNegative(unittest.TestCase):
|
|||
cbsize=(64, 64),
|
||||
psizes=[(64, 64)])
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue