mirror of
https://github.com/httpie/cli.git
synced 2025-01-08 14:49:41 +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 = {
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
<?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'>
|
||||||
|
@ -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