From d45d74ff5d625b1bde663880485603d3ac232311 Mon Sep 17 00:00:00 2001 From: John Evans Date: Tue, 18 Nov 2014 07:07:14 -0500 Subject: [PATCH] add test fixture for determining if openjpeg is installed --- glymur/test/fixtures.py | 9 +++++++++ glymur/test/test_jp2k.py | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/glymur/test/fixtures.py b/glymur/test/fixtures.py index 838756a..417797f 100644 --- a/glymur/test/fixtures.py +++ b/glymur/test/fixtures.py @@ -13,6 +13,15 @@ import six import glymur +# If openjpeg is not installed, many tests cannot be run. +if glymur.version.openjpeg_version == "0.0.0": + OPENJPEG_NOT_AVAILABLE = True + OPENJPEG_NOT_AVAILABLE_MSG = "OpenJPEG library not installed" +else: + OPENJPEG_NOT_AVAILABLE = False + OPENJPEG_NOT_AVAILABLE_MSG = None + + # Some versions of "six" on python3 cause problems when verifying warnings. # Only use when the version is 1.7 or higher. # And moreover, we only test using the 3.x infrastructure, never on 2.x. diff --git a/glymur/test/test_jp2k.py b/glymur/test/test_jp2k.py index 042a681..6a4b5c1 100644 --- a/glymur/test/test_jp2k.py +++ b/glymur/test/test_jp2k.py @@ -54,6 +54,8 @@ def load_tests(loader, tests, ignore): return tests +@unittest.skipIf(fixtures.OPENJPEG_NOT_AVAILABLE, + fixtures.OPENJPEG_NOT_AVAILABLE_MSG) class SliceProtocolBase(unittest.TestCase): """ Test slice protocol, i.e. when using [ ] to read image data. @@ -460,6 +462,8 @@ class TestSliceProtocolOpjData(unittest.TestCase): expected = self.j2k_quarter_data[5:13, 38:50] np.testing.assert_array_equal(actual, expected) +@unittest.skipIf(fixtures.OPENJPEG_NOT_AVAILABLE, + fixtures.OPENJPEG_NOT_AVAILABLE_MSG) class TestJp2k(unittest.TestCase): """These tests should be run by just about all configuration.""" @@ -966,6 +970,8 @@ class TestJp2k_write(unittest.TestCase): self.assertEqual(codestream.segment[2].spcod[0], glymur.core.CPRL) +@unittest.skipIf(fixtures.OPENJPEG_NOT_AVAILABLE, + fixtures.OPENJPEG_NOT_AVAILABLE_MSG) @unittest.skipIf(glymur.version.openjpeg_version_tuple[0] >= 2, "Negative tests only for version 1.x") class TestJp2k_1_x(unittest.TestCase):