mirror of
https://github.com/httpie/cli.git
synced 2025-01-07 14:19:30 +01:00
Fix XML formatter tests
This commit is contained in:
parent
6c501d23c3
commit
fdd486415a
@ -16,7 +16,7 @@ def parse_xml(data: str) -> 'Document':
|
|||||||
|
|
||||||
def pretty_xml(document: 'Document',
|
def pretty_xml(document: 'Document',
|
||||||
encoding: Optional[str] = UTF8,
|
encoding: Optional[str] = UTF8,
|
||||||
indent: int = 4,
|
indent: int = 2,
|
||||||
standalone: Optional[bool] = None) -> str:
|
standalone: Optional[bool] = None) -> str:
|
||||||
"""Render the given :class:`~xml.dom.minidom.Document` `document` into a prettified string."""
|
"""Render the given :class:`~xml.dom.minidom.Document` `document` into a prettified string."""
|
||||||
kwargs = {
|
kwargs = {
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN'
|
PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN'
|
||||||
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
|
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
|
||||||
<html>
|
<html>
|
||||||
<head/>
|
<head/>
|
||||||
<body>text</body>
|
<body>text</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
<?pi data?>
|
<?pi data?>
|
||||||
<!-- comment -->
|
<!-- comment -->
|
||||||
<root xmlns="namespace">
|
<root xmlns="namespace">
|
||||||
<element key="value">text</element>
|
<element key="value">text</element>
|
||||||
<element>text</element>
|
<element>text</element>
|
||||||
tail
|
tail
|
||||||
<empty-element/>
|
<empty-element/>
|
||||||
</root>
|
</root>
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!-- comment -->
|
<!-- comment -->
|
||||||
<root>
|
<root>
|
||||||
<element key="value">text</element>
|
<element key="value">text</element>
|
||||||
<element>text</element>
|
<element>text</element>
|
||||||
tail
|
tail
|
||||||
<empty-element/>
|
<empty-element/>
|
||||||
</root>
|
</root>
|
||||||
|
36
tests/fixtures/xmldata/xhtml/xhtml_formatted.xml
vendored
36
tests/fixtures/xmldata/xhtml/xhtml_formatted.xml
vendored
@ -2,28 +2,28 @@
|
|||||||
PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'
|
PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'
|
||||||
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
|
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||||
<title>XHTML 1.0 Strict Example</title>
|
<title>XHTML 1.0 Strict Example</title>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
//
|
//
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
function loadpdf() {
|
function loadpdf() {
|
||||||
document.getElementById("pdf-object").src="http://www.w3.org/TR/xhtml1/xhtml1.pdf";
|
document.getElementById("pdf-object").src="http://www.w3.org/TR/xhtml1/xhtml1.pdf";
|
||||||
}
|
}
|
||||||
//]]>
|
//]]>
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body onload="loadpdf()">
|
<body onload="loadpdf()">
|
||||||
<p>
|
<p>
|
||||||
This is an example of an
|
This is an example of an
|
||||||
<abbr title="Extensible HyperText Markup Language">XHTML</abbr>
|
<abbr title="Extensible HyperText Markup Language">XHTML</abbr>
|
||||||
1.0 Strict document.
|
1.0 Strict document.
|
||||||
<br/>
|
<br/>
|
||||||
<img id="validation-icon" src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Strict"/>
|
<img id="validation-icon" src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Strict"/>
|
||||||
<br/>
|
<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 id="pdf-object" name="pdf-object" type="application/pdf" data="http://www.w3.org/TR/xhtml1/xhtml1.pdf" width="100%" height="500">
|
||||||
</object>
|
</object>
|
||||||
</p>
|
</p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,30 +1,29 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!DOCTYPE html
|
<!DOCTYPE html
|
||||||
PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'
|
PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'
|
||||||
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
|
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
|
||||||
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
|
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
|
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
|
||||||
<title>XHTML 1.0 Strict Example</title>
|
<title>XHTML 1.0 Strict Example</title>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
//
|
//
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
function loadpdf() {
|
function loadpdf() {
|
||||||
document.getElementById("pdf-object").src="http://www.w3.org/TR/xhtml1/xhtml1.pdf";
|
document.getElementById("pdf-object").src="http://www.w3.org/TR/xhtml1/xhtml1.pdf";
|
||||||
}
|
}
|
||||||
//]]>
|
//]]>
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body onload="loadpdf()">
|
<body onload="loadpdf()">
|
||||||
<p>
|
<p>
|
||||||
This is an example of an
|
This is an example of an
|
||||||
<abbr title="Extensible HyperText Markup Language">XHTML</abbr>
|
<abbr title="Extensible HyperText Markup Language">XHTML</abbr>
|
||||||
1.0 Strict document.
|
1.0 Strict document.
|
||||||
<br/>
|
<br/>
|
||||||
<img alt="Valid XHTML 1.0 Strict" id="validation-icon" src="http://www.w3.org/Icons/valid-xhtml10"/>
|
<img alt="Valid XHTML 1.0 Strict" id="validation-icon" src="http://www.w3.org/Icons/valid-xhtml10"/>
|
||||||
<br/>
|
<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 data="http://www.w3.org/TR/xhtml1/xhtml1.pdf" height="500" id="pdf-object" name="pdf-object" type="application/pdf" width="100%">
|
||||||
</object>
|
</object>
|
||||||
</p>
|
</p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -379,7 +379,7 @@ class TestFormatOptions:
|
|||||||
},
|
},
|
||||||
'xml': {
|
'xml': {
|
||||||
'format': True,
|
'format': True,
|
||||||
'indent': 4,
|
'indent': 2,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
@ -398,7 +398,7 @@ class TestFormatOptions:
|
|||||||
},
|
},
|
||||||
'xml': {
|
'xml': {
|
||||||
'format': True,
|
'format': True,
|
||||||
'indent': 4,
|
'indent': 2,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
@ -419,7 +419,7 @@ class TestFormatOptions:
|
|||||||
},
|
},
|
||||||
'xml': {
|
'xml': {
|
||||||
'format': True,
|
'format': True,
|
||||||
'indent': 4,
|
'indent': 2,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
@ -436,7 +436,7 @@ class TestFormatOptions:
|
|||||||
[
|
[
|
||||||
'--format-options=json.indent:2',
|
'--format-options=json.indent:2',
|
||||||
'--format-options=xml.format:false',
|
'--format-options=xml.format:false',
|
||||||
'--format-options=xml.indent:2',
|
'--format-options=xml.indent:4',
|
||||||
'--unsorted',
|
'--unsorted',
|
||||||
'--no-unsorted',
|
'--no-unsorted',
|
||||||
],
|
],
|
||||||
@ -451,7 +451,7 @@ class TestFormatOptions:
|
|||||||
},
|
},
|
||||||
'xml': {
|
'xml': {
|
||||||
'format': False,
|
'format': False,
|
||||||
'indent': 2,
|
'indent': 4,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
@ -472,7 +472,7 @@ class TestFormatOptions:
|
|||||||
},
|
},
|
||||||
'xml': {
|
'xml': {
|
||||||
'format': True,
|
'format': True,
|
||||||
'indent': 4,
|
'indent': 2,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
@ -494,7 +494,7 @@ class TestFormatOptions:
|
|||||||
},
|
},
|
||||||
'xml': {
|
'xml': {
|
||||||
'format': True,
|
'format': True,
|
||||||
'indent': 4,
|
'indent': 2,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
@ -16,8 +16,8 @@ SAMPLE_XML_DATA = '<?xml version="1.0" encoding="utf-8"?><root><e>text</e></root
|
|||||||
'options, expected_xml',
|
'options, expected_xml',
|
||||||
[
|
[
|
||||||
('xml.format:false', SAMPLE_XML_DATA),
|
('xml.format:false', SAMPLE_XML_DATA),
|
||||||
('xml.indent:2', pretty_xml(parse_xml(SAMPLE_XML_DATA), indent=2)),
|
('xml.indent:2', pretty_xml(parse_xml(SAMPLE_XML_DATA))),
|
||||||
('xml.indent:4', pretty_xml(parse_xml(SAMPLE_XML_DATA))),
|
('xml.indent:4', pretty_xml(parse_xml(SAMPLE_XML_DATA), indent=4)),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@responses.activate
|
@responses.activate
|
||||||
@ -70,7 +70,6 @@ def test_xml_xhtml():
|
|||||||
content_type='application/xhtml+xml')
|
content_type='application/xhtml+xml')
|
||||||
|
|
||||||
r = http(url)
|
r = http(url)
|
||||||
print(r)
|
|
||||||
assert expected_xml_output in r
|
assert expected_xml_output in r
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user