diff --git a/glymur/jp2k.py b/glymur/jp2k.py index 3fffea1..1e6a790 100644 --- a/glymur/jp2k.py +++ b/glymur/jp2k.py @@ -167,7 +167,7 @@ class Jp2k(Jp2kBox): fps : int Frames per second, should be either 24 or 48. """ - if re.match("(1.5|2.0)", version.openjpeg_version) is not None: + if re.match("(1.5|2.0.0)", version.openjpeg_version) is not None: msg = "Writing Cinema2K or Cinema4K files is not supported with " msg += 'openjpeg library versions less than 2.0.1.' raise IOError(msg) @@ -1687,7 +1687,7 @@ def _validate_compression_params(img_array, cparams): msg = "{0}D imagery is not allowed.".format(img_array.ndim) raise IOError(msg) - if re.match("2.0", version.openjpeg_version) is not None: + if re.match("2.0.0", version.openjpeg_version) is not None: if (((img_array.ndim != 2) and (img_array.shape[2] != 1 and img_array.shape[2] != 3))): msg = "Writing images is restricted to single-channel " diff --git a/glymur/lib/test/test_openjp2.py b/glymur/lib/test/test_openjp2.py index 0abac84..67d6750 100644 --- a/glymur/lib/test/test_openjp2.py +++ b/glymur/lib/test/test_openjp2.py @@ -6,6 +6,7 @@ Tests for libopenjp2 wrapping functions. # pylint: disable=R0904,W0142 import os +import re import sys import tempfile import unittest @@ -15,17 +16,13 @@ import numpy as np import glymur from glymur.lib import openjp2 -OPENJP2_IS_V2_OFFICIAL = False -if openjp2.OPENJP2 is not None: - if not hasattr(openjp2.OPENJP2, - 'opj_stream_create_default_file_stream_v3'): - OPENJP2_IS_V2_OFFICIAL = True - @unittest.skipIf(os.name == "nt", "Temporary file issue on window.") @unittest.skipIf(openjp2.OPENJP2 is None, "Missing openjp2 library.") -@unittest.skipIf(OPENJP2_IS_V2_OFFICIAL, "API followed here specific to V2.0+") +@unittest.skipIf(re.match(r'''(1|2.0)''', + glymur.version.openjpeg_version) is not None, + "Not to be run until 2.1.0") class TestOpenJP2(unittest.TestCase): """Test openjp2 library functionality. diff --git a/glymur/test/fixtures.py b/glymur/test/fixtures.py index 683ecca..0fc5be1 100644 --- a/glymur/test/fixtures.py +++ b/glymur/test/fixtures.py @@ -25,14 +25,6 @@ try: except: HAS_PYTHON_XMP_TOOLKIT = False -# Need to know of the libopenjp2 version is the official 2.0.0 release and NOT -# the 2.0+ development version. -OPENJP2_IS_V2_OFFICIAL = False -if glymur.lib.openjp2.OPENJP2 is not None: - if not hasattr(glymur.lib.openjp2.OPENJP2, - 'opj_stream_create_default_file_stream_v3'): - OPENJP2_IS_V2_OFFICIAL = True - NO_READ_BACKEND_MSG = "Matplotlib with the PIL backend must be available in " NO_READ_BACKEND_MSG += "order to run the tests in this suite." diff --git a/glymur/test/test_jp2box.py b/glymur/test/test_jp2box.py index e19a097..d8866cf 100644 --- a/glymur/test/test_jp2box.py +++ b/glymur/test/test_jp2box.py @@ -36,7 +36,7 @@ from glymur.jp2box import JPEG2000SignatureBox from glymur.core import COLOR, OPACITY from glymur.core import RED, GREEN, BLUE, GREY, WHOLE_IMAGE -from .fixtures import OPENJP2_IS_V2_OFFICIAL, opj_data_file +from .fixtures import opj_data_file try: FORMAT_CORPUS_DATA_ROOT = os.environ['FORMAT_CORPUS_DATA_ROOT'] @@ -117,9 +117,9 @@ class TestDataEntryURL(unittest.TestCase): self.assertEqual(url + chr(0), read_url) -@unittest.skipIf(glymur.version.openjpeg_version_tuple[0] < 2 or - OPENJP2_IS_V2_OFFICIAL, - "Not supported until 2.0+.") +@unittest.skipIf(re.match(r'''(1|2.0.0)''', + glymur.version.openjpeg_version) is not None, + "Not supported until 2.1") @unittest.skipIf(os.name == "nt", "Temporary file issue on window.") class TestChannelDefinition(unittest.TestCase): """Test suite for channel definition boxes.""" diff --git a/glymur/test/test_jp2k.py b/glymur/test/test_jp2k.py index 7d2c911..f012c54 100644 --- a/glymur/test/test_jp2k.py +++ b/glymur/test/test_jp2k.py @@ -29,7 +29,7 @@ import pkg_resources import glymur from glymur import Jp2k -from .fixtures import HAS_PYTHON_XMP_TOOLKIT, OPENJP2_IS_V2_OFFICIAL +from .fixtures import HAS_PYTHON_XMP_TOOLKIT if HAS_PYTHON_XMP_TOOLKIT: import libxmp from libxmp import XMPMeta @@ -379,10 +379,9 @@ class TestJp2k(unittest.TestCase): creator_tool = xmp.get_property(libxmp.consts.XMP_NS_XMP, 'CreatorTool') self.assertEqual(creator_tool, 'Google') - @unittest.skipIf(fixtures.OPENJP2_IS_V2_OFFICIAL, - "Feature not supported in 2.0.0 official") - @unittest.skipIf(glymur.version.openjpeg_version_tuple[0] == 1, - "Feature not supported in 1.5") + @unittest.skipIf(re.match(r'''(1|2.0.0)''', + glymur.version.openjpeg_version) is not None, + "Not supported until 2.0.1") def test_jpx_mult_codestreams_jp2_brand(self): """Read JPX codestream when jp2-compatible.""" # The file in question has multiple codestreams. @@ -581,7 +580,8 @@ class TestJp2k_1_x(unittest.TestCase): j2k.read(layer=1) -@unittest.skipIf(not OPENJP2_IS_V2_OFFICIAL, +@unittest.skipIf(re.match(r'''2.0.0''', + glymur.version.openjpeg_version) is None, "Tests only to be run on 2.0 official.") class TestJp2k_2_0_official(unittest.TestCase): """Test suite to only be run on v2.0 official.""" @@ -679,9 +679,9 @@ class TestJp2k_2_0(unittest.TestCase): self.assertEqual(jasoc.box[3].box[1].box_id, 'xml ') -@unittest.skipIf(glymur.version.openjpeg_version_tuple[0] < 2 or - OPENJP2_IS_V2_OFFICIAL, - "Missing openjp2 library version 2.0+.") +@unittest.skipIf(re.match(r'''(1|2.0.0)''', + glymur.version.openjpeg_version) is not None, + "Not to be run until unless 2.0.1 or higher is present") class TestJp2k_2_1(unittest.TestCase): """Only to be run in 2.0+.""" diff --git a/glymur/test/test_opj_suite.py b/glymur/test/test_opj_suite.py index 899a5b5..f4534ef 100644 --- a/glymur/test/test_opj_suite.py +++ b/glymur/test/test_opj_suite.py @@ -38,7 +38,7 @@ import numpy as np from glymur import Jp2k import glymur -from .fixtures import OPENJP2_IS_V2_OFFICIAL, OPJ_DATA_ROOT +from .fixtures import OPJ_DATA_ROOT from .fixtures import mse, peak_tolerance, read_pgx, opj_data_file @@ -6599,10 +6599,9 @@ class TestSuite2point0(unittest.TestCase): @unittest.skipIf(OPJ_DATA_ROOT is None, "OPJ_DATA_ROOT environment variable not set") -@unittest.skipIf(OPENJP2_IS_V2_OFFICIAL, - "Test not in done in v2.0.0 official") -@unittest.skipIf(glymur.version.openjpeg_version_tuple[0] == 1, - "Tests not introduced until 2.1") +@unittest.skipIf(re.match(r'''(1|2.0.0)''', + glymur.version.openjpeg_version) is not None, + "Only supported in 2.0.1 or higher") class TestSuite2point1(unittest.TestCase): """Runs tests introduced in version 2.0+ or that pass only in 2.0+""" diff --git a/glymur/test/test_opj_suite_write.py b/glymur/test/test_opj_suite_write.py index c92c500..076f02b 100644 --- a/glymur/test/test_opj_suite_write.py +++ b/glymur/test/test_opj_suite_write.py @@ -29,10 +29,9 @@ import glymur @unittest.skipIf(not _HAS_SKIMAGE_FREEIMAGE_SUPPORT, "Cannot read input image without scikit-image/freeimage") @unittest.skipIf(os.name == "nt", "no write support on windows, period") -@unittest.skipIf(fixtures.OPENJP2_IS_V2_OFFICIAL, - "Feature not supported in 2.0.0 official") -@unittest.skipIf(glymur.version.openjpeg_version_tuple[0] == 1, - "Feature not supported in 1.5") +@unittest.skipIf(re.match(r'''(1|2.0.0)''', + glymur.version.openjpeg_version) is not None, + "Uses features not supported until 2.0.1") @unittest.skipIf(OPJ_DATA_ROOT is None, "OPJ_DATA_ROOT environment variable not set") class TestSuiteWriteCinema(unittest.TestCase): @@ -225,8 +224,8 @@ class TestSuiteWriteCinema(unittest.TestCase): @unittest.skipIf(not _HAS_SKIMAGE_FREEIMAGE_SUPPORT, "Cannot read input image without scikit-image/freeimage") @unittest.skipIf(os.name == "nt", "Temporary file issue on window.") -@unittest.skipIf(not re.match("(1.5|2.0)", glymur.version.openjpeg_version), - "Functionality implemented for 2.1") +@unittest.skipIf(not re.match("(1.5|2.0.0)", glymur.version.openjpeg_version), + "Functionality implemented for 2.0.1") @unittest.skipIf(OPJ_DATA_ROOT is None, "OPJ_OPJ_DATA_ROOT environment variable not set") class TestSuiteNegative2pointzero(unittest.TestCase):