From 4686c40c57a7fcd4b643496eb0714cbc629f5dee Mon Sep 17 00:00:00 2001 From: John Evans Date: Thu, 8 Jan 2015 12:07:10 -0500 Subject: [PATCH] fix test failure, not a real bug, closes #316 Had assumed that the error was due to parse_options not being properly reset, but that was not the case. Seems to have just been bad expected data. --- glymur/jp2box.py | 2 +- glymur/jp2k.py | 22 +++++++++++----------- glymur/test/fixtures.py | 4 ++-- glymur/test/test_jp2k.py | 4 +--- glymur/test/test_printing.py | 6 ++++-- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/glymur/jp2box.py b/glymur/jp2box.py index bc23ebe..98b0e6a 100644 --- a/glymur/jp2box.py +++ b/glymur/jp2box.py @@ -1032,7 +1032,7 @@ class ContiguousCodestreamBox(Jp2kBox): with open(self._filename, 'rb') as fptr: fptr.seek(self.main_header_offset) codestream = Codestream(fptr, self._length, - header_only=header_only) + header_only=header_only) self._codestream = codestream return self._codestream diff --git a/glymur/jp2k.py b/glymur/jp2k.py index d45f0db..ee6eedc 100644 --- a/glymur/jp2k.py +++ b/glymur/jp2k.py @@ -213,19 +213,19 @@ class Jp2k(Jp2kBox): num_components = len(cstr.segment[1].xrsiz) else: # try to get the image size from the IHDR box - jp2h = [box for box in self.box if box.box_id == 'jp2h'][0] - ihdr = [box for box in jp2h.box if box.box_id == 'ihdr'][0] + jp2h = [box for box in self.box if box.box_id == 'jp2h'][0] + ihdr = [box for box in jp2h.box if box.box_id == 'ihdr'][0] - height, width = ihdr.height, ihdr.width - num_components = ihdr.num_components + height, width = ihdr.height, ihdr.width + num_components = ihdr.num_components - if num_components == 1: - # but if there is a PCLR box, then we need to check that as - # well, as that turns a single-channel image into a - # multi-channel image - pclr = [box for box in jp2h.box if box.box_id == 'pclr'] - if len(pclr) > 0: - num_components = len(pclr[0].signed) + if num_components == 1: + # but if there is a PCLR box, then we need to check that as + # well, as that turns a single-channel image into a + # multi-channel image + pclr = [box for box in jp2h.box if box.box_id == 'pclr'] + if len(pclr) > 0: + num_components = len(pclr[0].signed) if num_components == 1: self.shape = (height, width) diff --git a/glymur/test/fixtures.py b/glymur/test/fixtures.py index 8d6165e..f6b8ef8 100644 --- a/glymur/test/fixtures.py +++ b/glymur/test/fixtures.py @@ -34,8 +34,8 @@ elif re.match('1.[0-6]', six.__version__) is not None: WARNING_INFRASTRUCTURE_ISSUE = True msg = "Cannot run test with version {0} of python-six" WARNING_INFRASTRUCTURE_MSG = msg.format(six.__version__) -elif ((re.match('1.8', six.__version__) is not None) and - (sys.platform.startswith('linux')) and +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() diff --git a/glymur/test/test_jp2k.py b/glymur/test/test_jp2k.py index 668f8d5..52945f9 100644 --- a/glymur/test/test_jp2k.py +++ b/glymur/test/test_jp2k.py @@ -39,6 +39,7 @@ from . import fixtures def docTearDown(doctest_obj): glymur.set_parseoptions(full_codestream=False) + # Doc tests should be run as well. def load_tests(loader, tests, ignore): """Should run doc tests as well""" @@ -1079,9 +1080,6 @@ class TestParsing(unittest.TestCase): class TestJp2kOpjDataRootWarnings(unittest.TestCase): """These tests should be run by just about all configuration.""" - def tearDown(self): - glymur.set_parseoptions(full_codestream=False) - def test_undecodeable_box_id(self): """Should warn in case of undecodeable box ID but not error out.""" filename = opj_data_file('input/nonregression/edf_c2_1013627.jp2') diff --git a/glymur/test/test_printing.py b/glymur/test/test_printing.py index 5310fa9..bccaa00 100644 --- a/glymur/test/test_printing.py +++ b/glymur/test/test_printing.py @@ -1065,12 +1065,14 @@ class TestJp2dump(unittest.TestCase): expected = '\n'.join(expected) self.assertEqual(actual, expected) - @unittest.skipIf(sys.hexversion < 0x03000000, "assertRegex not in 2.7") def test_jp2_codestream_0(self): """Verify dumping with -c 0, supressing all codestream details.""" actual = self.run_jp2dump(['', '-c', '0', self.jp2file]) - expected = fixtures.nemo_dump_no_codestream + # shave off the codestream details + lines = fixtures.nemo.split('\n') + expected = lines[0:105] + expected = '\n'.join(expected) self.assertEqual(actual, expected) def test_jp2_codestream_1(self):