use 3.x warning architecture
This commit is contained in:
parent
fc2a6c3075
commit
bfbc99d2da
1 changed files with 3 additions and 4 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue