Fix XML formatter tests

This commit is contained in:
Mickaël Schoentgen 2021-09-01 10:26:21 +02:00
parent 6c501d23c3
commit fdd486415a
8 changed files with 56 additions and 58 deletions

View File

@ -16,7 +16,7 @@ def parse_xml(data: str) -> 'Document':
def pretty_xml(document: 'Document',
encoding: Optional[str] = UTF8,
indent: int = 4,
indent: int = 2,
standalone: Optional[bool] = None) -> str:
"""Render the given :class:`~xml.dom.minidom.Document` `document` into a prettified string."""
kwargs = {

View File

@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html
PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>

View File

@ -379,7 +379,7 @@ class TestFormatOptions:
},
'xml': {
'format': True,
'indent': 4,
'indent': 2,
},
}
),
@ -398,7 +398,7 @@ class TestFormatOptions:
},
'xml': {
'format': True,
'indent': 4,
'indent': 2,
},
}
),
@ -419,7 +419,7 @@ class TestFormatOptions:
},
'xml': {
'format': True,
'indent': 4,
'indent': 2,
},
}
),
@ -436,7 +436,7 @@ class TestFormatOptions:
[
'--format-options=json.indent:2',
'--format-options=xml.format:false',
'--format-options=xml.indent:2',
'--format-options=xml.indent:4',
'--unsorted',
'--no-unsorted',
],
@ -451,7 +451,7 @@ class TestFormatOptions:
},
'xml': {
'format': False,
'indent': 2,
'indent': 4,
},
}
),
@ -472,7 +472,7 @@ class TestFormatOptions:
},
'xml': {
'format': True,
'indent': 4,
'indent': 2,
},
}
),
@ -494,7 +494,7 @@ class TestFormatOptions:
},
'xml': {
'format': True,
'indent': 4,
'indent': 2,
},
}
),

View File

@ -16,8 +16,8 @@ SAMPLE_XML_DATA = '<?xml version="1.0" encoding="utf-8"?><root><e>text</e></root
'options, expected_xml',
[
('xml.format:false', SAMPLE_XML_DATA),
('xml.indent:2', pretty_xml(parse_xml(SAMPLE_XML_DATA), indent=2)),
('xml.indent:4', pretty_xml(parse_xml(SAMPLE_XML_DATA))),
('xml.indent:2', pretty_xml(parse_xml(SAMPLE_XML_DATA))),
('xml.indent:4', pretty_xml(parse_xml(SAMPLE_XML_DATA), indent=4)),
]
)
@responses.activate
@ -70,7 +70,6 @@ def test_xml_xhtml():
content_type='application/xhtml+xml')
r = http(url)
print(r)
assert expected_xml_output in r