diff --git a/glymur/jp2box.py b/glymur/jp2box.py index 149af0a..5bbe733 100644 --- a/glymur/jp2box.py +++ b/glymur/jp2box.py @@ -1792,14 +1792,14 @@ class XMLBox(Jp2kBox): text = read_buffer.decode('utf-8') # Strip out any trailing nulls, as they can foul up XML parsing. - text = text.rstrip('\0') + text = text.rstrip(chr(0)) try: elt = ET.fromstring(text) xml = ET.ElementTree(elt) except ParseError as parse_error: msg = 'A problem was encountered while parsing an XML box:' - msg += '\n\n\t"{0}"\n\nNo XML was retrieved.' + msg += '\n\n\t"{0}"\n\nNo XML was retrieved.' msg = msg.format(str(parse_error)) warnings.warn(msg, UserWarning) xml = None diff --git a/glymur/test/fixtures.py b/glymur/test/fixtures.py index 39b4ac5..cbfbc3b 100644 --- a/glymur/test/fixtures.py +++ b/glymur/test/fixtures.py @@ -57,7 +57,7 @@ def read_pgx(pgx_file): header += chr(char[0]) header = header.rstrip() - tokens = re.split('\s', header) + tokens = re.split(r'\s', header) if (tokens[1][0] == 'M') and (sys.byteorder == 'little'): swapbytes = True diff --git a/glymur/test/test_callbacks.py b/glymur/test/test_callbacks.py index 47ec100..712dd5f 100644 --- a/glymur/test/test_callbacks.py +++ b/glymur/test/test_callbacks.py @@ -88,7 +88,7 @@ class TestCallbacks15(unittest.TestCase): with patch('sys.stdout', new=StringIO()) as fake_out: d = j.read(rlevel=1, verbose=True) actual = fake_out.getvalue().strip() - + regex = re.compile(r"""\[INFO\]\stile\s1\sof\s1\s+ \[INFO\]\s-\stiers-1\stook\s [0-9]+\.[0-9]+\ss\s+ diff --git a/glymur/test/test_jp2k.py b/glymur/test/test_jp2k.py index f0db4b7..6e1e7a0 100644 --- a/glymur/test/test_jp2k.py +++ b/glymur/test/test_jp2k.py @@ -7,6 +7,7 @@ import struct import sys import tempfile import uuid +from xml.etree import cElementTree as ET if sys.hexversion < 0x02070000: import unittest2 as unittest @@ -623,6 +624,8 @@ class TestJp2k(unittest.TestCase): self.assertEqual(jp2k.box[3].box_id, 'xml ') self.assertEqual(jp2k.box[3].offset, 77) self.assertEqual(jp2k.box[3].length, 36) + self.assertEqual(ET.tostring(jp2k.box[3].xml.getroot()), + b'this is a test') @unittest.skipIf(os.name == "nt", "NamedTemporaryFile issue on windows") def test_asoc_label_box(self): diff --git a/glymur/test/test_opj_suite.py b/glymur/test/test_opj_suite.py index b6de353..c2b5f15 100644 --- a/glymur/test/test_opj_suite.py +++ b/glymur/test/test_opj_suite.py @@ -3809,7 +3809,7 @@ class TestSuiteDump(unittest.TestCase): 32, 32, 131, 2002, 2002, 1888]) self.assertEqual(c.segment[3]._exponent, [17, 17, 17, 17, 16, 16, 16, 15, 15, 15, 14, 14, - 14, 13, 13, 13, 11, 11, 11, 11, 11, 11]) + 14, 13, 13, 13, 11, 11, 11, 11, 11, 11]) # COM: comment # Registration @@ -4596,10 +4596,10 @@ class TestSuiteDump(unittest.TestCase): self.assertEqual(c.segment[7].sqcc & 0x1f, 2) # none self.assertEqual(c.segment[7]._mantissa, [1824, 1776, 1776, 1728, 1792, 1792, 1760, 1872, - 1872, 1896, 5, 5, 71, 2003, 2003, 1890]) + 1872, 1896, 5, 5, 71, 2003, 2003, 1890]) self.assertEqual(c.segment[7]._exponent, [18, 18, 18, 18, 17, 17, 17, 16, 16, 16, 14, 14, - 14, 14, 14, 14]) + 14, 14, 14, 14]) # COM: comment # Registration @@ -5634,7 +5634,7 @@ class TestSuiteDump(unittest.TestCase): self.assertEqual(c.segment[3]._mantissa, [0] * 16) self.assertEqual(c.segment[3]._exponent, [18, 19, 19, 20, 19, 19, 20, 19, 19, 20, 19, 19, 20, - 19, 19, 20]) + 19, 19, 20]) # COM: comment # Registration