tests: fix generated_document tests with py 3.8 (#42359)
This commit is contained in:
parent
f31a57e803
commit
020ec09e9c
|
@ -12,6 +12,7 @@ import zipfile
|
|||
import base64
|
||||
from webtest import Upload, Hidden
|
||||
import mock
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
try:
|
||||
from PIL import Image
|
||||
|
@ -64,7 +65,15 @@ def assert_equal_zip(stream1, stream2):
|
|||
for name in z1.namelist():
|
||||
if name == 'styles.xml':
|
||||
continue
|
||||
t1, t2 = z1.read(name), z2.read(name)
|
||||
if name in ['content.xml', 'meta.xml']:
|
||||
t1, t2 = ET.tostring(ET.XML(z1.read(name))), ET.tostring(ET.XML(z2.read(name)))
|
||||
try:
|
||||
# >= python 3.8: tostring preserves attribute order; use canonicalize to sort them
|
||||
t1, t2 = ET.canonicalize(t1), ET.canonicalize(t2)
|
||||
except AttributeError:
|
||||
pass
|
||||
else:
|
||||
t1, t2 = z1.read(name), z2.read(name)
|
||||
assert t1 == t2, 'file "%s" differs' % name
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue