Compare commits

...
Sign in to create a new pull request.

2 commits

Author SHA1 Message Date
John Evans
16f310400f progress 2014-11-21 19:14:22 -05:00
John Evans
f4232e8879 passes on 32-bit linux mint 2014-11-21 17:56:52 -05:00
7 changed files with 28 additions and 5 deletions

View file

@ -484,7 +484,7 @@ class Jp2k(Jp2kBox):
This method can only be used to create JPEG 2000 images that can fit This method can only be used to create JPEG 2000 images that can fit
in memory. in memory.
""" """
if re.match("1.[0-4]", version.openjpeg_version) is not None: if re.match("0|1.[0-4]", version.openjpeg_version) is not None:
raise RuntimeError("You must have at least version 1.5 of OpenJPEG " raise RuntimeError("You must have at least version 1.5 of OpenJPEG "
"in order to write images.") "in order to write images.")

View file

@ -144,7 +144,7 @@ def glymur_config():
lst.append(load_openjpeg_library(libname)) lst.append(load_openjpeg_library(libname))
if all(handle is None for handle in lst): if all(handle is None for handle in lst):
msg = "Neither the openjp2 nor the openjpeg library could be loaded. " msg = "Neither the openjp2 nor the openjpeg library could be loaded. "
raise IOError(msg) warnings.warn(msg)
return tuple(lst) return tuple(lst)
def get_configdir(): def get_configdir():

View file

@ -17,7 +17,7 @@ import glymur
from . import fixtures from . import fixtures
@unittest.skipIf(sys.hexversion < 0x03000000, "do not care about 2.7 here") @unittest.skipIf(sys.hexversion < 0x03000000, "do not care about 2.7 here")
@unittest.skipIf(re.match('1|2.0', glymur.version.openjpeg_version), @unittest.skipIf(re.match('0|1|2.0', glymur.version.openjpeg_version),
"Requires openjpeg 2.1.0 or higher") "Requires openjpeg 2.1.0 or higher")
class TestPrintingOpenjp2(unittest.TestCase): class TestPrintingOpenjp2(unittest.TestCase):
"""Tests for verifying how printing works on openjp2 library structures.""" """Tests for verifying how printing works on openjp2 library structures."""

View file

@ -13,6 +13,14 @@ import six
import glymur 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. # Some versions of "six" on python3 cause problems when verifying warnings.
# Only use when the version is 1.7 or higher. # Only use when the version is 1.7 or higher.
# And moreover, we only test using the 3.x infrastructure, never on 2.x. # And moreover, we only test using the 3.x infrastructure, never on 2.x.

View file

@ -65,6 +65,8 @@ class TestCallbacks(unittest.TestCase):
expected = '[INFO] tile number 1 / 1' expected = '[INFO] tile number 1 / 1'
self.assertEqual(actual, expected) self.assertEqual(actual, expected)
@unittest.skipIf(glymur.version.openjpeg_version[0] == '0',
"Missing openjpeg/openjp2 library.")
def test_info_callbacks_on_read(self): def test_info_callbacks_on_read(self):
"""stdio output when info callback handler is enabled""" """stdio output when info callback handler is enabled"""

View file

@ -114,7 +114,7 @@ class TestDataEntryURL(unittest.TestCase):
self.assertEqual(url + chr(0), read_url) self.assertEqual(url + chr(0), read_url)
@unittest.skipIf(re.match(r'''(1|2.0.0)''', @unittest.skipIf(re.match(r'''0|1|2.0.0''',
glymur.version.openjpeg_version) is not None, glymur.version.openjpeg_version) is not None,
"Not supported until 2.1") "Not supported until 2.1")
@unittest.skipIf(os.name == "nt", WINDOWS_TMP_FILE_MSG) @unittest.skipIf(os.name == "nt", WINDOWS_TMP_FILE_MSG)

View file

@ -36,6 +36,7 @@ from glymur.version import openjpeg_version
from .fixtures import HAS_PYTHON_XMP_TOOLKIT from .fixtures import HAS_PYTHON_XMP_TOOLKIT
from .fixtures import WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG from .fixtures import WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG
from .fixtures import OPENJPEG_NOT_AVAILABLE, OPENJPEG_NOT_AVAILABLE_MSG
if HAS_PYTHON_XMP_TOOLKIT: if HAS_PYTHON_XMP_TOOLKIT:
import libxmp import libxmp
@ -76,6 +77,7 @@ class SliceProtocolBase(unittest.TestCase):
self.j2k_data_r1 = self.j2k[::2, ::2] self.j2k_data_r1 = self.j2k[::2, ::2]
self.j2k_data_r5 = self.j2k[::32, ::32] self.j2k_data_r5 = self.j2k[::32, ::32]
@unittest.skipIf(OPENJPEG_NOT_AVAILABLE, OPENJPEG_NOT_AVAILABLE_MSG)
@unittest.skipIf(re.match("1.5|2", glymur.version.openjpeg_version) is None, @unittest.skipIf(re.match("1.5|2", glymur.version.openjpeg_version) is None,
"Must have openjpeg 1.5 or higher to run") "Must have openjpeg 1.5 or higher to run")
@unittest.skipIf(os.name == "nt", fixtures.WINDOWS_TMP_FILE_MSG) @unittest.skipIf(os.name == "nt", fixtures.WINDOWS_TMP_FILE_MSG)
@ -143,6 +145,7 @@ class TestSliceProtocolBaseWrite(SliceProtocolBase):
j[:25, :45, :] = self.j2k_data[:25, :25, :] j[:25, :45, :] = self.j2k_data[:25, :25, :]
@unittest.skipIf(OPENJPEG_NOT_AVAILABLE, OPENJPEG_NOT_AVAILABLE_MSG)
class TestSliceProtocolRead(SliceProtocolBase): class TestSliceProtocolRead(SliceProtocolBase):
def test_resolution_strides_cannot_differ(self): def test_resolution_strides_cannot_differ(self):
@ -251,6 +254,7 @@ class TestJp2k(unittest.TestCase):
def tearDown(self): def tearDown(self):
pass pass
@unittest.skipIf(OPENJPEG_NOT_AVAILABLE, OPENJPEG_NOT_AVAILABLE_MSG)
@unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG)
def test_warn_if_using_read_method(self): def test_warn_if_using_read_method(self):
"""Should warn if deprecated read method is called""" """Should warn if deprecated read method is called"""
@ -313,6 +317,7 @@ class TestJp2k(unittest.TestCase):
actdata = j2[:] actdata = j2[:]
self.assertTrue(fixtures.mse(actdata[0], expdata[0]) < 0.38) self.assertTrue(fixtures.mse(actdata[0], expdata[0]) < 0.38)
@unittest.skipIf(OPENJPEG_NOT_AVAILABLE, OPENJPEG_NOT_AVAILABLE_MSG)
@unittest.skipIf(re.match('1.[0-4]', openjpeg_version) is not None, @unittest.skipIf(re.match('1.[0-4]', openjpeg_version) is not None,
"Not supported with OpenJPEG {0}".format(openjpeg_version)) "Not supported with OpenJPEG {0}".format(openjpeg_version))
@unittest.skipIf(re.match('1.5.(1|2)', openjpeg_version) is not None, @unittest.skipIf(re.match('1.5.(1|2)', openjpeg_version) is not None,
@ -345,6 +350,7 @@ class TestJp2k(unittest.TestCase):
self.assertEqual(newjp2.filename, self.j2kfile) self.assertEqual(newjp2.filename, self.j2kfile)
self.assertEqual(len(newjp2.box), 0) self.assertEqual(len(newjp2.box), 0)
@unittest.skipIf(OPENJPEG_NOT_AVAILABLE, OPENJPEG_NOT_AVAILABLE_MSG)
@unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG)
def test_rlevel_max_backwards_compatibility(self): def test_rlevel_max_backwards_compatibility(self):
""" """
@ -367,6 +373,7 @@ class TestJp2k(unittest.TestCase):
np.testing.assert_array_equal(thumbnail1, thumbnail2) np.testing.assert_array_equal(thumbnail1, thumbnail2)
self.assertEqual(thumbnail1.shape, (25, 15, 3)) self.assertEqual(thumbnail1.shape, (25, 15, 3))
@unittest.skipIf(OPENJPEG_NOT_AVAILABLE, OPENJPEG_NOT_AVAILABLE_MSG)
def test_rlevel_too_high(self): def test_rlevel_too_high(self):
"""Should error out appropriately if reduce level too high""" """Should error out appropriately if reduce level too high"""
j = Jp2k(self.jp2file) j = Jp2k(self.jp2file)
@ -518,12 +525,14 @@ class TestJp2k(unittest.TestCase):
self.assertEqual(new_jp2.box[j].length, self.assertEqual(new_jp2.box[j].length,
baseline_jp2.box[j].length) baseline_jp2.box[j].length)
@unittest.skipIf(OPENJPEG_NOT_AVAILABLE, OPENJPEG_NOT_AVAILABLE_MSG)
def test_basic_jp2(self): def test_basic_jp2(self):
"""Just a very basic test that reading a JP2 file does not error out. """Just a very basic test that reading a JP2 file does not error out.
""" """
j2k = Jp2k(self.jp2file) j2k = Jp2k(self.jp2file)
j2k[::2, ::2] j2k[::2, ::2]
@unittest.skipIf(OPENJPEG_NOT_AVAILABLE, OPENJPEG_NOT_AVAILABLE_MSG)
def test_basic_j2k(self): def test_basic_j2k(self):
"""This test is only useful when openjp2 is not available """This test is only useful when openjp2 is not available
and OPJ_DATA_ROOT is not set. We need at least one and OPJ_DATA_ROOT is not set. We need at least one
@ -648,6 +657,7 @@ class TestJp2k(unittest.TestCase):
creator_tool = xmp.get_property(libxmp.consts.XMP_NS_XMP, 'CreatorTool') creator_tool = xmp.get_property(libxmp.consts.XMP_NS_XMP, 'CreatorTool')
self.assertEqual(creator_tool, 'Google') self.assertEqual(creator_tool, 'Google')
@unittest.skipIf(OPENJPEG_NOT_AVAILABLE, OPENJPEG_NOT_AVAILABLE_MSG)
@unittest.skipIf(re.match(r'''(1|2.0.0)''', @unittest.skipIf(re.match(r'''(1|2.0.0)''',
glymur.version.openjpeg_version) is not None, glymur.version.openjpeg_version) is not None,
"Not supported until 2.0.1") "Not supported until 2.0.1")
@ -664,6 +674,7 @@ class TestJp2k(unittest.TestCase):
with self.assertRaises(RuntimeError): with self.assertRaises(RuntimeError):
glymur.Jp2k(self.jp2file).read_bands() glymur.Jp2k(self.jp2file).read_bands()
@unittest.skipIf(OPENJPEG_NOT_AVAILABLE, OPENJPEG_NOT_AVAILABLE_MSG)
@unittest.skipIf(re.match('1.[0-4]', openjpeg_version) is not None, @unittest.skipIf(re.match('1.[0-4]', openjpeg_version) is not None,
"Not supported with OpenJPEG {0}".format(openjpeg_version)) "Not supported with OpenJPEG {0}".format(openjpeg_version))
@unittest.skipIf(os.name == "nt", fixtures.WINDOWS_TMP_FILE_MSG) @unittest.skipIf(os.name == "nt", fixtures.WINDOWS_TMP_FILE_MSG)
@ -869,6 +880,7 @@ class TestJp2k_1_x(unittest.TestCase):
@unittest.skipIf(os.name == "nt", fixtures.WINDOWS_TMP_FILE_MSG) @unittest.skipIf(os.name == "nt", fixtures.WINDOWS_TMP_FILE_MSG)
@unittest.skipIf(OPENJPEG_NOT_AVAILABLE, OPENJPEG_NOT_AVAILABLE_MSG)
class Test_2p0_official(unittest.TestCase): class Test_2p0_official(unittest.TestCase):
"""Tests specific to v2.0.0""" """Tests specific to v2.0.0"""
@ -962,6 +974,7 @@ class TestJp2k_2_0(unittest.TestCase):
self.assertEqual(jasoc.box[3].box[1].box_id, 'xml ') self.assertEqual(jasoc.box[3].box[1].box_id, 'xml ')
@unittest.skipIf(OPENJPEG_NOT_AVAILABLE, OPENJPEG_NOT_AVAILABLE_MSG)
@unittest.skipIf(re.match(r'''(1|2.0.0)''', @unittest.skipIf(re.match(r'''(1|2.0.0)''',
glymur.version.openjpeg_version) is not None, glymur.version.openjpeg_version) is not None,
"Not to be run until unless 2.0.1 or higher is present") "Not to be run until unless 2.0.1 or higher is present")
@ -1135,7 +1148,7 @@ class TestJp2kOpjDataRoot(unittest.TestCase):
actdata = j[:] actdata = j[:]
self.assertTrue(fixtures.mse(actdata, expdata) < 250) self.assertTrue(fixtures.mse(actdata, expdata) < 250)
@unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG)
def test_no_cxform_pclr_jp2(self): def test_no_cxform_pclr_jp2(self):
"""Indices for pclr jpxfile if no color transform""" """Indices for pclr jpxfile if no color transform"""