From d00f84b6ebc657eb295551b13e7764353b8ca436 Mon Sep 17 00:00:00 2001 From: jevans Date: Thu, 21 Aug 2014 19:48:26 -0400 Subject: [PATCH] moved test_exceeded_box_length into test_glymur_warnings --- glymur/test/test_glymur_warnings.py | 19 +++++++++++++++++++ glymur/test/test_opj_suite_neg.py | 13 +------------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/glymur/test/test_glymur_warnings.py b/glymur/test/test_glymur_warnings.py index 6d5c1e3..7c3c422 100644 --- a/glymur/test/test_glymur_warnings.py +++ b/glymur/test/test_glymur_warnings.py @@ -28,6 +28,25 @@ from .fixtures import opj_data_file, OPJ_DATA_ROOT class TestWarnings(unittest.TestCase): """Test suite for warnings issued by glymur.""" + def test_exceeded_box_length(self): + """ + should warn if reading past end of a box + + Verify that a warning is issued if we read past the end of a box + This file has a palette (pclr) box whose length is impossibly + short. + """ + infile = os.path.join(OPJ_DATA_ROOT, + 'input/nonregression/mem-b2ace68c-1381.jp2') + regex = re.compile(r'''Encountered\san\sunrecoverable\sValueError\s + while\sparsing\sa\spclr\sbox\sat\sbyte\soffset\s + \d+\.\s+The\soriginal\serror\smessage\swas\s + "total\ssize\sof\snew\sarray\smust\sbe\s + unchanged"''', + re.VERBOSE) + with self.assertWarnsRegex(UserWarning, regex): + Jp2k(infile) + def test_NR_DEC_issue188_beach_64bitsbox_jp2_41_decode(self): """ Has an 'XML ' box instead of 'xml '. Yes that is pedantic, but it diff --git a/glymur/test/test_opj_suite_neg.py b/glymur/test/test_opj_suite_neg.py index 5a475a2..0020803 100644 --- a/glymur/test/test_opj_suite_neg.py +++ b/glymur/test/test_opj_suite_neg.py @@ -83,7 +83,7 @@ class TestSuiteNegative(unittest.TestCase): relpath = 'input/nonregression/illegalcolortransform.j2k' jfile = opj_data_file(relpath) jp2k = Jp2k(jfile) - with warnings.catch_warnings(record=True) as w: + with warnings.catch_warnings(): warnings.simplefilter('ignore') codestream = jp2k.get_codestream(header_only=False) @@ -119,17 +119,6 @@ class TestSuiteNegative(unittest.TestCase): with self.assertRaises(IOError): j.write(data, cbsize=(2, 2048)) - def test_exceeded_box(self): - """should warn if reading past end of a box""" - # Verify that a warning is issued if we read past the end of a box - # This file has a palette (pclr) box whose length is impossibly - # short. - infile = os.path.join(OPJ_DATA_ROOT, - 'input/nonregression/mem-b2ace68c-1381.jp2') - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter('ignore') - Jp2k(infile) - @unittest.skipIf(os.name == "nt", "Temporary file issue on window.") def test_precinct_size_not_p2(self): """precinct sizes should be powers of two."""