get all tests passing

This commit is contained in:
John Evans 2015-01-06 11:00:08 -05:00
commit fe5e784b58
8 changed files with 36 additions and 29 deletions

View file

@ -1034,8 +1034,8 @@ class ContiguousCodestreamBox(Jp2kBox):
return self._codestream return self._codestream
def __repr__(self): def __repr__(self):
msg = "glymur.jp2box.ContiguousCodeStreamBox(main_header={0})" msg = "glymur.jp2box.ContiguousCodeStreamBox(codestream={0})"
return msg.format(repr(self.main_header)) return msg.format(repr(self.codestream))
def __str__(self): def __str__(self):
msg = Jp2kBox.__str__(self) msg = Jp2kBox.__str__(self)

View file

@ -2,6 +2,7 @@
Test fixtures common to more than one test point. Test fixtures common to more than one test point.
""" """
import os import os
import platform
import re import re
import sys import sys
import textwrap import textwrap
@ -33,6 +34,14 @@ elif re.match('1.[0-6]', six.__version__) is not None:
WARNING_INFRASTRUCTURE_ISSUE = True WARNING_INFRASTRUCTURE_ISSUE = True
msg = "Cannot run test with version {0} of python-six" msg = "Cannot run test with version {0} of python-six"
WARNING_INFRASTRUCTURE_MSG = msg.format(six.__version__) WARNING_INFRASTRUCTURE_MSG = msg.format(six.__version__)
elif ((re.match('1.8', six.__version__) is not None) and
(sys.platform.startswith('linux')) and
(platform.linux_distribution() == ('LinuxMint', '17', 'qiana'))):
WARNING_INFRASTRUCTURE_ISSUE = True
linux_distribution = platform.linux_distribution()
msg = "Cannot run test with version {0} of python-six on {1}"
WARNING_INFRASTRUCTURE_MSG = msg.format(six.__version__,
platform.linux_distribution)
# Cannot reopen a named temporary file in windows. # Cannot reopen a named temporary file in windows.
WINDOWS_TMP_FILE_MSG = "cannot use NamedTemporaryFile like this in windows" WINDOWS_TMP_FILE_MSG = "cannot use NamedTemporaryFile like this in windows"

View file

@ -20,6 +20,13 @@ from .fixtures import WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG
class TestWarnings(unittest.TestCase): class TestWarnings(unittest.TestCase):
"""Test suite for warnings issued by glymur.""" """Test suite for warnings issued by glymur."""
def test_invalid_compatibility_list_entry(self):
"""should not error out with invalid compatibility list entry"""
filename = opj_data_file('input/nonregression/issue397.jp2')
with self.assertWarns(UserWarning):
Jp2k(filename)
self.assertTrue(True)
def test_exceeded_box_length(self): def test_exceeded_box_length(self):
""" """
should warn if reading past end of a box should warn if reading past end of a box

View file

@ -1016,7 +1016,7 @@ class TestJp2Boxes(unittest.TestCase):
"""Raw instantiation should not produce a main_header.""" """Raw instantiation should not produce a main_header."""
box = ContiguousCodestreamBox() box = ContiguousCodestreamBox()
self.assertEqual(box.box_id, 'jp2c') self.assertEqual(box.box_id, 'jp2c')
self.assertIsNone(box.main_header) self.assertIsNone(box.codestream)
def test_codestream_main_header_offset(self): def test_codestream_main_header_offset(self):
"""main_header_offset is an attribute of the CCS box""" """main_header_offset is an attribute of the CCS box"""
@ -1318,7 +1318,7 @@ class TestRepr(MetadataBase):
# Difficult to eval(repr()) this, so just match the general pattern. # Difficult to eval(repr()) this, so just match the general pattern.
regexp = "glymur.jp2box.ContiguousCodeStreamBox" regexp = "glymur.jp2box.ContiguousCodeStreamBox"
regexp += "[(]main_header=<glymur.codestream.Codestream\sobject\s" regexp += "[(]codestream=<glymur.codestream.Codestream\sobject\s"
regexp += "at\s0x([a-fA-F0-9]*)>[)]" regexp += "at\s0x([a-fA-F0-9]*)>[)]"
if sys.hexversion < 0x03000000: if sys.hexversion < 0x03000000:

View file

@ -272,15 +272,6 @@ class TestJp2k(unittest.TestCase):
jp2 = Jp2k(jfile) jp2 = Jp2k(jfile)
self.assertEqual(jp2.shape, (128, 128)) self.assertEqual(jp2.shape, (128, 128))
@unittest.skipIf(OPJ_DATA_ROOT is None,
"OPJ_DATA_ROOT environment variable not set")
def test_invalid_compatibility_list_entry(self):
"""should not error out with invalid compatibility list entry"""
filename = opj_data_file('input/nonregression/issue397.jp2')
with self.assertWarns(UserWarning):
Jp2k(filename)
self.assertTrue(True)
def test_shape_j2k(self): def test_shape_j2k(self):
"""verify shape attribute for J2K file """verify shape attribute for J2K file
""" """
@ -1074,9 +1065,9 @@ class TestParsing(unittest.TestCase):
glymur.set_parseoptions(codestream=False) glymur.set_parseoptions(codestream=False)
jp2 = Jp2k(self.jp2file) jp2 = Jp2k(self.jp2file)
jp2c = jp2.box[4] jp2c = jp2.box[4]
self.assertIsNone(jp2c._main_header) self.assertIsNone(jp2c._codestream)
jp2c.main_header jp2c.codestream
self.assertIsNotNone(jp2c._main_header) self.assertIsNotNone(jp2c._codestream)
@unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG) @unittest.skipIf(WARNING_INFRASTRUCTURE_ISSUE, WARNING_INFRASTRUCTURE_MSG)

View file

@ -385,7 +385,7 @@ class TestSuiteWarns(MetadataBase):
expected = ColourSpecificationBox(colorspace=glymur.core.SRGB) expected = ColourSpecificationBox(colorspace=glymur.core.SRGB)
self.verifyColourSpecificationBox(jp2.box[2].box[1], expected) self.verifyColourSpecificationBox(jp2.box[2].box[1], expected)
c = jp2.box[3].main_header c = jp2.box[3].codestream
ids = [x.marker_id for x in c.segment] ids = [x.marker_id for x in c.segment]
expected = ['SOC', 'SIZ', 'CME', 'COD', 'QCD', 'QCC', 'QCC'] expected = ['SOC', 'SIZ', 'CME', 'COD', 'QCD', 'QCC', 'QCC']

View file

@ -52,7 +52,7 @@ class TestSuite(MetadataBase):
colr = glymur.jp2box.ColourSpecificationBox(colorspace=glymur.core.YCC) colr = glymur.jp2box.ColourSpecificationBox(colorspace=glymur.core.YCC)
self.verifyColourSpecificationBox(jp2.box[2].box[1], colr) self.verifyColourSpecificationBox(jp2.box[2].box[1], colr)
c = jp2.box[3].main_header c = jp2.box[3].codestream
ids = [x.marker_id for x in c.segment] ids = [x.marker_id for x in c.segment]
expected = ['SOC', 'SIZ', 'COD', 'QCD'] expected = ['SOC', 'SIZ', 'COD', 'QCD']
@ -2584,7 +2584,7 @@ class TestSuite(MetadataBase):
self.assertEqual(jp2.box[3].box[3].mapping_type, (1, 1, 1)) self.assertEqual(jp2.box[3].box[3].mapping_type, (1, 1, 1))
self.assertEqual(jp2.box[3].box[3].palette_index, (0, 1, 2)) self.assertEqual(jp2.box[3].box[3].palette_index, (0, 1, 2))
c = jp2.box[4].main_header c = jp2.box[4].codestream
ids = [x.marker_id for x in c.segment] ids = [x.marker_id for x in c.segment]
expected = ['SOC', 'SIZ', 'COD', 'QCD'] expected = ['SOC', 'SIZ', 'COD', 'QCD']
@ -2648,7 +2648,7 @@ class TestSuite(MetadataBase):
precedence=2) precedence=2)
self.verifyColourSpecificationBox(jp2.box[3].box[1], colr) self.verifyColourSpecificationBox(jp2.box[3].box[1], colr)
c = jp2.box[4].main_header c = jp2.box[4].codestream
ids = [x.marker_id for x in c.segment] ids = [x.marker_id for x in c.segment]
expected = ['SOC', 'SIZ', 'COD', 'QCD'] expected = ['SOC', 'SIZ', 'COD', 'QCD']
@ -2711,7 +2711,7 @@ class TestSuite(MetadataBase):
self.assertEqual(jp2.box[2].box[2].channel_type, (0, 1)) # opacity self.assertEqual(jp2.box[2].box[2].channel_type, (0, 1)) # opacity
self.assertEqual(jp2.box[2].box[2].association, (0, 0)) # both main self.assertEqual(jp2.box[2].box[2].association, (0, 0)) # both main
c = jp2.box[3].main_header c = jp2.box[3].codestream
ids = [x.marker_id for x in c.segment] ids = [x.marker_id for x in c.segment]
expected = ['SOC', 'SIZ', 'COD', 'QCD', 'CME'] expected = ['SOC', 'SIZ', 'COD', 'QCD', 'CME']
@ -2794,7 +2794,7 @@ class TestSuite(MetadataBase):
self.assertEqual(jp2.box[3].box[3].mapping_type, (1, 1, 1)) self.assertEqual(jp2.box[3].box[3].mapping_type, (1, 1, 1))
self.assertEqual(jp2.box[3].box[3].palette_index, (0, 1, 2)) self.assertEqual(jp2.box[3].box[3].palette_index, (0, 1, 2))
c = jp2.box[4].main_header c = jp2.box[4].codestream
ids = [x.marker_id for x in c.segment] ids = [x.marker_id for x in c.segment]
expected = ['SOC', 'SIZ', 'COD', 'QCD'] expected = ['SOC', 'SIZ', 'COD', 'QCD']
@ -2848,7 +2848,7 @@ class TestSuite(MetadataBase):
colr = glymur.jp2box.ColourSpecificationBox(colorspace=glymur.core.YCC) colr = glymur.jp2box.ColourSpecificationBox(colorspace=glymur.core.YCC)
self.verifyColourSpecificationBox(jp2.box[2].box[1], colr) self.verifyColourSpecificationBox(jp2.box[2].box[1], colr)
c = jp2.box[3].main_header c = jp2.box[3].codestream
ids = [x.marker_id for x in c.segment] ids = [x.marker_id for x in c.segment]
expected = ['SOC', 'SIZ', 'COD', 'QCD', 'POD'] expected = ['SOC', 'SIZ', 'COD', 'QCD', 'POD']
@ -2916,7 +2916,7 @@ class TestSuiteWarns(MetadataBase):
with self.assertWarns(UserWarning): with self.assertWarns(UserWarning):
jp2 = Jp2k(jfile) jp2 = Jp2k(jfile)
self.assertEqual(jp2.box[-1].main_header.segment[-1].marker_id, 'QCC') self.assertEqual(jp2.box[-1].codestream.segment[-1].marker_id, 'QCC')
def test_NR_broken2_jp2_dump(self): def test_NR_broken2_jp2_dump(self):
""" """
@ -2927,7 +2927,7 @@ class TestSuiteWarns(MetadataBase):
# Invalid marker ID on codestream. # Invalid marker ID on codestream.
jp2 = Jp2k(jfile) jp2 = Jp2k(jfile)
self.assertEqual(jp2.box[-1].main_header.segment[-1].marker_id, 'QCC') self.assertEqual(jp2.box[-1].codestream.segment[-1].marker_id, 'QCC')
def test_NR_file1_dump(self): def test_NR_file1_dump(self):
jfile = opj_data_file('input/conformance/file1.jp2') jfile = opj_data_file('input/conformance/file1.jp2')
@ -3243,7 +3243,7 @@ class TestSuiteWarns(MetadataBase):
# Skip the 4th box, it is uknown. # Skip the 4th box, it is uknown.
c = jp2.box[4].main_header c = jp2.box[4].codestream
ids = [x.marker_id for x in c.segment] ids = [x.marker_id for x in c.segment]
expected = ['SOC', 'SIZ', 'COD', 'QCD', 'CME', 'CME'] expected = ['SOC', 'SIZ', 'COD', 'QCD', 'CME', 'CME']
@ -3303,7 +3303,7 @@ class TestSuiteWarns(MetadataBase):
self.assertIsNone(jp2.box[2].box[1].icc_profile) self.assertIsNone(jp2.box[2].box[1].icc_profile)
self.assertIsNone(jp2.box[2].box[1].colorspace) self.assertIsNone(jp2.box[2].box[1].colorspace)
c = jp2.box[3].main_header c = jp2.box[3].codestream
ids = [x.marker_id for x in c.segment] ids = [x.marker_id for x in c.segment]
expected = ['SOC', 'SIZ', 'COD', 'QCD'] expected = ['SOC', 'SIZ', 'COD', 'QCD']
@ -3366,7 +3366,7 @@ class TestSuiteWarns(MetadataBase):
self.assertIsNone(jp2.box[2].box[1].icc_profile) self.assertIsNone(jp2.box[2].box[1].icc_profile)
self.assertIsNone(jp2.box[2].box[1].colorspace) self.assertIsNone(jp2.box[2].box[1].colorspace)
c = jp2.box[3].main_header c = jp2.box[3].codestream
ids = [x.marker_id for x in c.segment] ids = [x.marker_id for x in c.segment]
expected = ['SOC', 'SIZ', 'COD', 'QCD'] expected = ['SOC', 'SIZ', 'COD', 'QCD']

View file

@ -632,7 +632,7 @@ class TestSuiteWrite(fixtures.MetadataBase):
self.assertIsNone(jp2.box[2].box[1].icc_profile) self.assertIsNone(jp2.box[2].box[1].icc_profile)
self.assertEqual(jp2.box[2].box[1].colorspace, glymur.core.SRGB) self.assertEqual(jp2.box[2].box[1].colorspace, glymur.core.SRGB)
codestream = jp2.box[3].main_header codestream = jp2.box[3].codestream
kwargs = {'rsiz': 0, 'xysiz': (640, 480), 'xyosiz': (0, 0), kwargs = {'rsiz': 0, 'xysiz': (640, 480), 'xyosiz': (0, 0),
'xytsiz': (640, 480), 'xytosiz': (0, 0), 'xytsiz': (640, 480), 'xytosiz': (0, 0),