Merge branch 'refactor' into devel
This commit is contained in:
commit
14f060dffb
1 changed files with 34 additions and 18 deletions
|
|
@ -50,19 +50,13 @@ def chdir(dirname=None):
|
||||||
|
|
||||||
class TestJp2k(unittest.TestCase):
|
class TestJp2k(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
@classmethod
|
||||||
self.jp2file = pkg_resources.resource_filename(glymur.__name__,
|
def setUpClass(cls):
|
||||||
|
jp2file = pkg_resources.resource_filename(glymur.__name__,
|
||||||
"data/nemo.jp2")
|
"data/nemo.jp2")
|
||||||
|
with tempfile.NamedTemporaryFile(suffix='.jp2', delete=False) as tfile:
|
||||||
def tearDown(self):
|
cls._bad_xml_file = tfile.name
|
||||||
pass
|
with open(jp2file, 'rb') as ifile:
|
||||||
|
|
||||||
@unittest.skipIf(sys.hexversion < 0x03020000,
|
|
||||||
"Uses features introduced in 3.2.")
|
|
||||||
def test_invalid_xml_box(self):
|
|
||||||
# Should be able to recover from xml box with bad xml.
|
|
||||||
with tempfile.NamedTemporaryFile(suffix='.jp2') as tfile:
|
|
||||||
with open(self.jp2file, 'rb') as ifile:
|
|
||||||
# Everything up until the jp2c box.
|
# Everything up until the jp2c box.
|
||||||
buffer = ifile.read(77)
|
buffer = ifile.read(77)
|
||||||
tfile.write(buffer)
|
tfile.write(buffer)
|
||||||
|
|
@ -81,13 +75,35 @@ class TestJp2k(unittest.TestCase):
|
||||||
tfile.write(buffer)
|
tfile.write(buffer)
|
||||||
tfile.flush()
|
tfile.flush()
|
||||||
|
|
||||||
with self.assertWarns(UserWarning) as cw:
|
@classmethod
|
||||||
jp2k = Jp2k(tfile.name)
|
def tearDownClass(cls):
|
||||||
|
os.unlink(cls._bad_xml_file)
|
||||||
|
|
||||||
self.assertEqual(jp2k.box[3].id, 'xml ')
|
def setUp(self):
|
||||||
self.assertEqual(jp2k.box[3].offset, 77)
|
self.jp2file = pkg_resources.resource_filename(glymur.__name__,
|
||||||
self.assertEqual(jp2k.box[3].length, 28)
|
"data/nemo.jp2")
|
||||||
self.assertIsNone(jp2k.box[3].xml)
|
|
||||||
|
def tearDown(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
@unittest.skipIf(sys.hexversion < 0x03020000,
|
||||||
|
"Uses features introduced in 3.2.")
|
||||||
|
def test_invalid_xml_box_warning(self):
|
||||||
|
# Should be able to recover from xml box with bad xml.
|
||||||
|
# Just verify that a warning is issued on 3.2+
|
||||||
|
with self.assertWarns(UserWarning) as cw:
|
||||||
|
jp2k = Jp2k(self._bad_xml_file)
|
||||||
|
|
||||||
|
def test_invalid_xml_box(self):
|
||||||
|
# Should be able to recover from xml box with bad xml.
|
||||||
|
with warnings.catch_warnings():
|
||||||
|
warnings.simplefilter("ignore")
|
||||||
|
jp2k = Jp2k(self._bad_xml_file)
|
||||||
|
|
||||||
|
self.assertEqual(jp2k.box[3].id, 'xml ')
|
||||||
|
self.assertEqual(jp2k.box[3].offset, 77)
|
||||||
|
self.assertEqual(jp2k.box[3].length, 28)
|
||||||
|
self.assertIsNone(jp2k.box[3].xml)
|
||||||
|
|
||||||
def test_bad_area_parameter(self):
|
def test_bad_area_parameter(self):
|
||||||
# Verify that we error out appropriately if given a bad area parameter.
|
# Verify that we error out appropriately if given a bad area parameter.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue