Tests passing on bare 2.6.6 python. #104

This commit is contained in:
John Evans 2014-01-24 15:35:23 -05:00
commit 6d340a5a8a
3 changed files with 28 additions and 7 deletions

View file

@ -11,6 +11,18 @@ import numpy as np
import glymur
# The Python XMP Toolkit may be used for XMP UUIDs, but only if available and
# if the version is at least 2.0.0.
try:
import libxmp
if hasattr(libxmp, 'version') and re.match('[2-9].\d*.\d*', libxmp.version.VERSION):
from libxmp import XMPMeta
HAS_PYTHON_XMP_TOOLKIT = True
else:
HAS_PYTHON_XMP_TOOLKIT = False
except ImportError:
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

View file

@ -35,7 +35,9 @@ if sys.hexversion <= 0x03030000:
else:
from unittest.mock import patch
from libxmp import XMPMeta
from .fixtures import HAS_PYTHON_XMP_TOOLKIT, OPJ_DATA_ROOT
if HAS_PYTHON_XMP_TOOLKIT:
from libxmp import XMPMeta
import glymur
from glymur import Jp2k
@ -66,9 +68,13 @@ class TestUUIDXMP(unittest.TestCase):
actual_ids = [b.box_id for b in jp2.box]
self.assertEqual(actual_ids, expected_ids)
# The data should be an XMP packet, which gets interpreted as
# an ElementTree.
self.assertTrue(isinstance(jp2.box[-1].data, XMPMeta))
# The data should be an XMP packet
if HAS_PYTHON_XMP_TOOLKIT:
# when python xmp toolkit is available.
self.assertTrue(isinstance(jp2.box[-1].data, XMPMeta))
else:
# when python xmp toolkit is not available.
self.assertTrue(isinstance(jp2.box[-1].data, str))
class TestUUIDExif(unittest.TestCase):
"""Tests for UUIDs of Exif type."""

View file

@ -30,12 +30,13 @@ import warnings
import numpy as np
import pkg_resources
import libxmp
import glymur
from glymur import Jp2k
from .fixtures import OPENJP2_IS_V2_OFFICIAL
from .fixtures import HAS_PYTHON_XMP_TOOLKIT, OPENJP2_IS_V2_OFFICIAL
if HAS_PYTHON_XMP_TOOLKIT:
import libxmp
from .fixtures import OPJ_DATA_ROOT, opj_data_file
@ -361,6 +362,8 @@ class TestJp2k(unittest.TestCase):
self.assertEqual(ET.tostring(jp2k.box[3].xml.getroot()),
b'<test>this is a test</test>')
@unittest.skipIf(not HAS_PYTHON_XMP_TOOLKIT,
"Requires Python XMP Toolkit >= 2.0")
def test_xmp_attribute(self):
"""Verify the XMP packet in the shipping example file can be read."""
j = Jp2k(self.jp2file)