use 3.x warning architecture

This commit is contained in:
John Evans 2014-09-16 20:04:38 -04:00
commit bfbc99d2da

View file

@ -62,17 +62,16 @@ class TestICC(unittest.TestCase):
self.assertEqual(profile['Creator'], 'JPEG')
@unittest.skipIf(sys.hexversion < 0x03020000, "assertWarns not until 3.2")
def test_invalid_profile_header(self):
"""invalid ICC header data should cause UserWarning"""
jfile = opj_data_file('input/nonregression/orb-blue10-lin-jp2.jp2')
# assertWarns in Python 3.3 (python2.7/pylint issue)
# pylint: disable=E1101
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter('always')
regex = 'ICC profile header is corrupt'
with self.assertWarnsRegex(UserWarning, regex):
Jp2k(jfile)
self.assertTrue(issubclass(w[0].category,UserWarning))
self.assertTrue('ICC profile header is corrupt' in str(w[0].message))
if __name__ == "__main__":
unittest.main()