From fdd486415a24503426213478c46d00a306b99e89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Schoentgen?= Date: Wed, 1 Sep 2021 10:26:21 +0200 Subject: [PATCH] Fix XML formatter tests --- httpie/output/formatters/xml.py | 2 +- .../fixtures/xmldata/valid/dtd_formatted.xml | 4 +- .../xmldata/valid/simple-ns_formatted.xml | 8 ++-- .../xmldata/valid/simple_formatted.xml | 8 ++-- .../xmldata/xhtml/xhtml_formatted.xml | 36 +++++++++--------- .../xhtml_formatted_python_less_than_3.8.xml | 37 +++++++++---------- tests/test_output.py | 14 +++---- tests/test_xml.py | 5 +-- 8 files changed, 56 insertions(+), 58 deletions(-) diff --git a/httpie/output/formatters/xml.py b/httpie/output/formatters/xml.py index be2cd248..e5ce5c23 100644 --- a/httpie/output/formatters/xml.py +++ b/httpie/output/formatters/xml.py @@ -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 = { diff --git a/tests/fixtures/xmldata/valid/dtd_formatted.xml b/tests/fixtures/xmldata/valid/dtd_formatted.xml index c196becb..372c93b8 100644 --- a/tests/fixtures/xmldata/valid/dtd_formatted.xml +++ b/tests/fixtures/xmldata/valid/dtd_formatted.xml @@ -3,6 +3,6 @@ PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'> - - text + + text diff --git a/tests/fixtures/xmldata/valid/simple-ns_formatted.xml b/tests/fixtures/xmldata/valid/simple-ns_formatted.xml index 607f2c74..8273afca 100644 --- a/tests/fixtures/xmldata/valid/simple-ns_formatted.xml +++ b/tests/fixtures/xmldata/valid/simple-ns_formatted.xml @@ -2,8 +2,8 @@ - text - text - tail - + text + text + tail + diff --git a/tests/fixtures/xmldata/valid/simple_formatted.xml b/tests/fixtures/xmldata/valid/simple_formatted.xml index 31973fa6..1638b5b6 100644 --- a/tests/fixtures/xmldata/valid/simple_formatted.xml +++ b/tests/fixtures/xmldata/valid/simple_formatted.xml @@ -1,8 +1,8 @@ - text - text - tail - + text + text + tail + diff --git a/tests/fixtures/xmldata/xhtml/xhtml_formatted.xml b/tests/fixtures/xmldata/xhtml/xhtml_formatted.xml index 67bbdb33..a1e99c80 100644 --- a/tests/fixtures/xmldata/xhtml/xhtml_formatted.xml +++ b/tests/fixtures/xmldata/xhtml/xhtml_formatted.xml @@ -2,28 +2,28 @@ PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'> - - - XHTML 1.0 Strict Example - - - -

- This is an example of an - XHTML - 1.0 Strict document. -
- Valid XHTML 1.0 Strict -
- + //]]> + + + +

+ This is an example of an + XHTML + 1.0 Strict document. +
+ Valid XHTML 1.0 Strict +
+ -

- +

+ diff --git a/tests/fixtures/xmldata/xhtml/xhtml_formatted_python_less_than_3.8.xml b/tests/fixtures/xmldata/xhtml/xhtml_formatted_python_less_than_3.8.xml index 7e6eced3..5987e103 100644 --- a/tests/fixtures/xmldata/xhtml/xhtml_formatted_python_less_than_3.8.xml +++ b/tests/fixtures/xmldata/xhtml/xhtml_formatted_python_less_than_3.8.xml @@ -1,30 +1,29 @@ - - - - XHTML 1.0 Strict Example - - - -

- This is an example of an - XHTML - 1.0 Strict document. -
- Valid XHTML 1.0 Strict -
- + //]]> + + + +

+ This is an example of an + XHTML + 1.0 Strict document. +
+ Valid XHTML 1.0 Strict +
+ -

- +

+ diff --git a/tests/test_output.py b/tests/test_output.py index 1a9d9dad..0d0ee2f0 100644 --- a/tests/test_output.py +++ b/tests/test_output.py @@ -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, }, } ), diff --git a/tests/test_xml.py b/tests/test_xml.py index a91a583a..a956d7f5 100644 --- a/tests/test_xml.py +++ b/tests/test_xml.py @@ -16,8 +16,8 @@ SAMPLE_XML_DATA = 'text