mirror of
https://github.com/ceph/s3-tests.git
synced 2025-05-14 11:11:20 +00:00
Work on tests.
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
This commit is contained in:
parent
5d158567fd
commit
819eecba5c
2 changed files with 172 additions and 72 deletions
|
@ -258,7 +258,7 @@ def with_setup_kwargs(setup, teardown=None):
|
|||
# yield _test_gen
|
||||
|
||||
|
||||
def normalize_xml_whitespace(xml, pretty_print=True):
|
||||
def normalize_xml(xml, pretty_print=True):
|
||||
root = etree.fromstring(xml.encode(encoding='ascii'))
|
||||
|
||||
for element in root.iter('*'):
|
||||
|
@ -271,10 +271,14 @@ def normalize_xml_whitespace(xml, pretty_print=True):
|
|||
if element.tail is not None:
|
||||
element.tail = element.tail.strip().replace("\n", "").replace("\r", "")
|
||||
|
||||
# Sort the elements
|
||||
for parent in root.xpath('//*[./*]'): # Search for parent elements
|
||||
parent[:] = sorted(parent,key=lambda x: x.tag)
|
||||
|
||||
xmlstr = etree.tostring(root, encoding="utf-8", xml_declaration=True, pretty_print=pretty_print)
|
||||
# there are two different DTD URIs
|
||||
xmlstr = re.sub(r'xmlns="[^"]+"', 'xmlns="DTD-URI"', xmlstr)
|
||||
xmlstr = re.sub(r'xmlns=\'[^\']+\'', 'xmlns="DTD-URI"', xmlstr)
|
||||
xmlstr = re.sub(r'xmlns="[^"]+"', 'xmlns="s3"', xmlstr)
|
||||
xmlstr = re.sub(r'xmlns=\'[^\']+\'', 'xmlns="s3"', xmlstr)
|
||||
for uri in ['http://doc.s3.amazonaws.com/doc/2006-03-01/', 'http://s3.amazonaws.com/doc/2006-03-01/']:
|
||||
xmlstr = xmlstr.replace(uri, 'URI-DTD')
|
||||
#xmlstr = re.sub(r'>\s+', '>', xmlstr, count=0, flags=re.MULTILINE)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue