1
0
mirror of https://github.com/httpie/cli.git synced 2024-11-24 08:22:22 +02:00

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

@ -3,6 +3,6 @@
PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN'
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html>
<head/>
<body>text</body>
<head/>
<body>text</body>
</html>

View File

@ -2,8 +2,8 @@
<?pi data?>
<!-- comment -->
<root xmlns="namespace">
<element key="value">text</element>
<element>text</element>
tail
<empty-element/>
<element key="value">text</element>
<element>text</element>
tail
<empty-element/>
</root>

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- comment -->
<root>
<element key="value">text</element>
<element>text</element>
tail
<empty-element/>
<element key="value">text</element>
<element>text</element>
tail
<empty-element/>
</root>

View File

@ -2,28 +2,28 @@
PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>XHTML 1.0 Strict Example</title>
<script type="text/javascript">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>XHTML 1.0 Strict Example</title>
<script type="text/javascript">
//
<![CDATA[
function loadpdf() {
document.getElementById("pdf-object").src="http://www.w3.org/TR/xhtml1/xhtml1.pdf";
}
//]]>
</script>
</head>
<body onload="loadpdf()">
<p>
This is an example of an
<abbr title="Extensible HyperText Markup Language">XHTML</abbr>
1.0 Strict document.
<br/>
<img id="validation-icon" src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Strict"/>
<br/>
<object id="pdf-object" name="pdf-object" type="application/pdf" data="http://www.w3.org/TR/xhtml1/xhtml1.pdf" width="100%" height="500">
//]]>
</script>
</head>
<body onload="loadpdf()">
<p>
This is an example of an
<abbr title="Extensible HyperText Markup Language">XHTML</abbr>
1.0 Strict document.
<br/>
<img id="validation-icon" src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Strict"/>
<br/>
<object id="pdf-object" name="pdf-object" type="application/pdf" data="http://www.w3.org/TR/xhtml1/xhtml1.pdf" width="100%" height="500">
</object>
</p>
</body>
</p>
</body>
</html>

View File

@ -1,30 +1,29 @@
<?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'>
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
<title>XHTML 1.0 Strict Example</title>
<script type="text/javascript">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
<title>XHTML 1.0 Strict Example</title>
<script type="text/javascript">
//
<![CDATA[
function loadpdf() {
document.getElementById("pdf-object").src="http://www.w3.org/TR/xhtml1/xhtml1.pdf";
}
//]]>
</script>
</head>
<body onload="loadpdf()">
<p>
This is an example of an
<abbr title="Extensible HyperText Markup Language">XHTML</abbr>
1.0 Strict document.
<br/>
<img alt="Valid XHTML 1.0 Strict" id="validation-icon" src="http://www.w3.org/Icons/valid-xhtml10"/>
<br/>
<object data="http://www.w3.org/TR/xhtml1/xhtml1.pdf" height="500" id="pdf-object" name="pdf-object" type="application/pdf" width="100%">
//]]>
</script>
</head>
<body onload="loadpdf()">
<p>
This is an example of an
<abbr title="Extensible HyperText Markup Language">XHTML</abbr>
1.0 Strict document.
<br/>
<img alt="Valid XHTML 1.0 Strict" id="validation-icon" src="http://www.w3.org/Icons/valid-xhtml10"/>
<br/>
<object data="http://www.w3.org/TR/xhtml1/xhtml1.pdf" height="500" id="pdf-object" name="pdf-object" type="application/pdf" width="100%">
</object>
</p>
</body>
</p>
</body>
</html>

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