From 35288ce73e44e1a4d78440c9d59029d4f97d350d Mon Sep 17 00:00:00 2001 From: John Evans Date: Tue, 30 Jul 2013 09:50:30 -0400 Subject: [PATCH 1/4] Bad predicate in unittest decorator for TestCallbacks15. #90 --- glymur/test/test_callbacks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/glymur/test/test_callbacks.py b/glymur/test/test_callbacks.py index d1a06c5..2d4a3de 100644 --- a/glymur/test/test_callbacks.py +++ b/glymur/test/test_callbacks.py @@ -66,7 +66,7 @@ class TestCallbacks(unittest.TestCase): self.assertEqual(actual, expected) -@unittest.skipIf(glymur.lib.openjp2.OPENJPEG is None, +@unittest.skipIf(glymur.lib.openjpeg.OPENJPEG is None, "Missing openjpeg library.") class TestCallbacks15(unittest.TestCase): """This test suite is for OpenJPEG 1.5.1 properties. From 93270a0d501ad8261742b2af14929e607a9d11e2 Mon Sep 17 00:00:00 2001 From: John Evans Date: Tue, 30 Jul 2013 09:51:40 -0400 Subject: [PATCH 2/4] Removed monkey-patching of the library version when not found. #90 --- glymur/lib/openjpeg.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/glymur/lib/openjpeg.py b/glymur/lib/openjpeg.py index 56bdfd3..704cf9c 100644 --- a/glymur/lib/openjpeg.py +++ b/glymur/lib/openjpeg.py @@ -28,9 +28,6 @@ else: # Does not really matter. But version should not be called if there is no # OpenJPEG library found. _MINOR = 0 - # Redefine version so that we can use it. - def version(): - return '0.0.0' class EventMgrType(ctypes.Structure): From 6581540f34004090ab40584248accc1808f1fb0f Mon Sep 17 00:00:00 2001 From: John Evans Date: Tue, 30 Jul 2013 09:52:07 -0400 Subject: [PATCH 3/4] Added monkey-patched fixture for openjpeg version. --- glymur/test/fixtures.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/glymur/test/fixtures.py b/glymur/test/fixtures.py index 3e5cfbb..39b4ac5 100644 --- a/glymur/test/fixtures.py +++ b/glymur/test/fixtures.py @@ -5,6 +5,14 @@ import numpy as np import glymur +# Need to know the openjpeg version. If openjpeg is not installed, we use +# '0.0.0' +OPENJPEG_VERSION = '0.0.0' +if glymur.lib.openjpeg.OPENJPEG is not None: + OPENJPEG_VERSION = glymur.lib.openjpeg.version() + +# 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, From 3f417a30b100c9eb9dc91150c67896b8a3dd4de8 Mon Sep 17 00:00:00 2001 From: John Evans Date: Tue, 30 Jul 2013 09:52:53 -0400 Subject: [PATCH 4/4] Use monkey-patched openjpeg version when library not available. Closes #92 --- glymur/test/test_opj_suite.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/glymur/test/test_opj_suite.py b/glymur/test/test_opj_suite.py index b42e033..b6de353 100644 --- a/glymur/test/test_opj_suite.py +++ b/glymur/test/test_opj_suite.py @@ -30,6 +30,7 @@ import numpy as np from glymur import Jp2k import glymur +from .fixtures import OPENJPEG_VERSION from .fixtures import OPENJP2_IS_V2_OFFICIAL from .fixtures import * @@ -7801,7 +7802,8 @@ class TestSuite15(unittest.TestCase): jfile = os.path.join(data_root, 'input/conformance/file9.jp2') jp2k = Jp2k(jfile) jpdata = jp2k.read() - if glymur.lib.openjpeg.version().startswith('1.3'): + if re.match('[01]\.3', OPENJPEG_VERSION): + # Version 1.3 reads in the image as the palette indices. self.assertEqual(jpdata.shape, (512, 768)) else: self.assertEqual(jpdata.shape, (512, 768, 3)) @@ -7840,7 +7842,7 @@ class TestSuite15(unittest.TestCase): data = jp2.read() self.assertTrue(True) - @unittest.skipIf(int(glymur.lib.openjpeg.version().split('.')[1]) < 5, + @unittest.skipIf(re.match('[01]\.[34]', OPENJPEG_VERSION), "Segfaults openjpeg 1.4 and earlier.") def test_NR_DEC_broken2_jp2_5_decode(self): # Null pointer access @@ -7863,7 +7865,7 @@ class TestSuite15(unittest.TestCase): with self.assertRaises(ValueError) as ce: d = j.read() - @unittest.skipIf(int(glymur.lib.openjpeg.version().split('.')[1]) < 5, + @unittest.skipIf(re.match('[01]\.[34]', OPENJPEG_VERSION), "Segfaults openjpeg 1.4 and earlier.") def test_NR_DEC_broken4_jp2_7_decode(self): # Null pointer access