all tests passing on opensuse

This commit is contained in:
John Evans 2015-01-06 19:55:59 -05:00
commit 059bee50e2
4 changed files with 36 additions and 20 deletions

View file

@ -69,7 +69,7 @@ class TestWarnings(unittest.TestCase):
\(\d+\)\.""",
re.VERBOSE)
with self.assertWarnsRegex(UserWarning, regex):
Jp2k(jfile)
Jp2k(jfile).get_codestream()
@unittest.skipIf(re.match("1.5|2.0.0", glymur.version.openjpeg_version),
"Test not passing on 1.5.x, not introduced until 2.x")
@ -84,7 +84,7 @@ class TestWarnings(unittest.TestCase):
\(\d+\)\.""",
re.VERBOSE)
with self.assertWarnsRegex(UserWarning, regex):
Jp2k(jfile)
Jp2k(jfile).get_codestream()
def test_NR_gdal_fuzzer_check_comp_dx_dy_jp2_dump(self):
"""
@ -97,7 +97,7 @@ class TestWarnings(unittest.TestCase):
dx=\d+,\s*dy=\d+""",
re.VERBOSE)
with self.assertWarnsRegex(UserWarning, regex):
Jp2k(jfile)
Jp2k(jfile).get_codestream()
def test_NR_gdal_fuzzer_assert_in_opj_j2k_read_SQcd_SQcc_patch_jp2(self):
lst = ['input', 'nonregression',
@ -107,32 +107,32 @@ class TestWarnings(unittest.TestCase):
number\sof\scomponents\sis\sonly\s\d+""",
re.VERBOSE)
with self.assertWarnsRegex(UserWarning, regex):
Jp2k(jfile)
Jp2k(jfile).get_codestream()
def test_bad_rsiz(self):
"""Should warn if RSIZ is bad. Issue196"""
filename = opj_data_file('input/nonregression/edf_c2_1002767.jp2')
with self.assertWarnsRegex(UserWarning, 'Invalid profile'):
Jp2k(filename)
Jp2k(filename).get_codestream()
def test_bad_wavelet_transform(self):
"""Should warn if wavelet transform is bad. Issue195"""
filename = opj_data_file('input/nonregression/edf_c2_10025.jp2')
with self.assertWarnsRegex(UserWarning, 'Invalid wavelet transform'):
Jp2k(filename)
Jp2k(filename).get_codestream()
def test_invalid_progression_order(self):
"""Should still be able to parse even if prog order is invalid."""
jfile = opj_data_file('input/nonregression/2977.pdf.asan.67.2198.jp2')
with self.assertWarnsRegex(UserWarning, 'Invalid progression order'):
Jp2k(jfile)
Jp2k(jfile).get_codestream()
def test_tile_height_is_zero(self):
"""Zero tile height should not cause an exception."""
filename = 'input/nonregression/2539.pdf.SIGFPE.706.1712.jp2'
filename = opj_data_file(filename)
with self.assertWarnsRegex(UserWarning, 'Invalid tile dimensions'):
Jp2k(filename)
Jp2k(filename).get_codestream()
@unittest.skipIf(os.name == "nt", "Temporary file issue on window.")
def test_unknown_marker_segment(self):

View file

@ -36,6 +36,9 @@ from .fixtures import OPJ_DATA_ROOT, opj_data_file
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"""
@ -43,7 +46,8 @@ def load_tests(loader, tests, ignore):
# Can't do it on windows, temporary file issue.
return tests
if glymur.lib.openjp2.OPENJP2 is not None:
tests.addTests(doctest.DocTestSuite('glymur.jp2k'))
tests.addTests(doctest.DocTestSuite('glymur.jp2k',
tearDown=docTearDown))
return tests
@ -1075,6 +1079,9 @@ 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')

View file

@ -4,6 +4,7 @@ suite.
"""
import re
import unittest
import warnings
import numpy as np
@ -2913,21 +2914,29 @@ class TestSuiteWarns(MetadataBase):
def test_NR_broken4_jp2_dump(self):
jfile = opj_data_file('input/nonregression/broken4.jp2')
with self.assertWarns(UserWarning):
jp2 = Jp2k(jfile)
self.assertEqual(jp2.box[-1].codestream.segment[-1].marker_id, 'QCC')
with warnings.catch_warnings():
# Suppress a warning, all we really care is parsing the entire
# file.
warnings.simplefilter("ignore")
with self.assertWarns(UserWarning):
jp2 = Jp2k(jfile)
self.assertEqual(jp2.box[-1].codestream.segment[-1].marker_id,
'QCC')
def test_NR_broken2_jp2_dump(self):
"""
Invalid marker ID in the codestream.
"""
jfile = opj_data_file('input/nonregression/broken2.jp2')
with self.assertWarns(UserWarning):
# Invalid marker ID on codestream.
jp2 = Jp2k(jfile)
self.assertEqual(jp2.box[-1].codestream.segment[-1].marker_id, 'QCC')
with warnings.catch_warnings():
# Suppress a warning, all we really care is parsing the entire
# file.
warnings.simplefilter("ignore")
with self.assertWarns(UserWarning):
# Invalid marker ID on codestream.
jp2 = Jp2k(jfile)
self.assertEqual(jp2.box[-1].codestream.segment[-1].marker_id,
'QCC')
def test_NR_file1_dump(self):
jfile = opj_data_file('input/conformance/file1.jp2')

View file

@ -42,7 +42,7 @@ class TestPrinting(unittest.TestCase):
glymur.set_printoptions(short=False, xml=True, codestream=True)
def tearDown(self):
pass
glymur.set_parseoptions(full_codestream=False)
def test_version_info(self):
"""Should be able to print(glymur.version.info)"""
@ -854,7 +854,7 @@ class TestPrintingOpjDataRootWarns(unittest.TestCase):
"""Should still be able to print if rsiz is bad, issue196"""
filename = opj_data_file('input/nonregression/edf_c2_1002767.jp2')
with self.assertWarns(UserWarning):
j = Jp2k(filename)
j = Jp2k(filename).get_codestream()
with patch('sys.stdout', new=StringIO()):
print(j)