Skip to content

WIP: Use lxml #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ name = "pypi"

[packages]
typing = "*"
lxml = "*"

[dev-packages]
pytest = "==3.8.0"
Expand All @@ -15,7 +16,7 @@ coverage = "*"
sphinx = "*"
"doc8" = "*"
codecov = "*"
cosmic-ray-pytest-runner = {version = "*", python_version = ">= '3.6'"}
cosmic-ray = {version = "*", python_version = ">= '3.6'"}
cosmic-ray-pytest-runner = {version = "*",python_version = ">= '3.6'"}
cosmic-ray = {version = "*",python_version = ">= '3.6'"}
attrs = "*"
mypy = {version = "==0.630", python_version = ">= '3.6'"}
mypy = {version = "==0.630",python_version = ">= '3.6'"}
2 changes: 1 addition & 1 deletion declxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
)
import warnings
from xml.dom import minidom # type: ignore
import xml.etree.ElementTree as ET
from lxml import etree as ET


_PY2 = sys.version_info[0] == 2
Expand Down
2 changes: 1 addition & 1 deletion tests/test_hooks_value_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ def test_primitive_transform_attribute():
"""Transform a primitive value that is an attribute"""
xml_string = strip_xml("""
<data>
<element value="3" />
<element value="3"/>
</data>
""")

Expand Down
23 changes: 11 additions & 12 deletions tests/test_serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def test_array_serialize_array_of_arrays_omit_empty():
<value>2</value>
<value>4</value>
</test-run>
<test-run />
<test-run/>
<test-run>
<value>12</value>
<value>32</value>
Expand All @@ -123,7 +123,6 @@ def test_array_serialize_array_of_arrays_omit_empty():
""")

actual = xml.serialize_to_string(processor, value)

assert expected == actual


Expand Down Expand Up @@ -180,7 +179,7 @@ def test_array_serialize_missing_optional_nested():
expected = strip_xml("""
<root>
<message>Hello</message>
<data />
<data/>
</root>
""")

Expand Down Expand Up @@ -366,7 +365,7 @@ def test_array_serialize_primitive_omit_empty():
expected = strip_xml("""
<root>
<value>Hello</value>
<value />
<value></value>
<value>Hola</value>
<value>Bonjour</value>
</root>
Expand Down Expand Up @@ -447,7 +446,7 @@ def test_attribute_serialize():

expected = strip_xml("""
<root>
<element value="Hello, World" />
<element value="Hello, World"/>
</root>
""")

Expand All @@ -468,7 +467,7 @@ def test_attribute_serialize_aliased():

expected = strip_xml("""
<root>
<constant value="3.14" />
<constant value="3.14"/>
</root>
""")

Expand Down Expand Up @@ -1027,7 +1026,7 @@ def test_primitive_values_serialize_falsey():
<boolean>False</boolean>
<float>0.0</float>
<int>0</int>
<string />
<string></string>
</root>
""")

Expand All @@ -1053,7 +1052,7 @@ def test_primitive_values_serialize_falsey_omitted():
])

expected = strip_xml("""
<root />
<root/>
""")

actual = xml.serialize_to_string(processor, value)
Expand All @@ -1074,10 +1073,10 @@ def test_primitive_values_serialize_none_default():

expected = strip_xml("""
<root>
<boolean />
<float />
<int />
<string />
<boolean></boolean>
<float></float>
<int></int>
<string></string>
</root>
""")

Expand Down
10 changes: 5 additions & 5 deletions tests/test_xpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class TestDot(_ProcessorTestCase):

xml_string = strip_xml("""
<files>
<file name="a.txt" size="236" />
<file name="b.txt" size="7654" />
<file name="a.txt" size="236"/>
<file name="b.txt" size="7654"/>
</files>
""")

Expand Down Expand Up @@ -218,9 +218,9 @@ class TestSlashFromRootArray(_ProcessorTestCase):
xml_string = strip_xml("""
<locations>
<cities>
<city name="Kansas City" state="MO" />
<city name="Lincoln" state="NE" />
<city name="Salt Lake City" state="UT" />
<city name="Kansas City" state="MO"/>
<city name="Lincoln" state="NE"/>
<city name="Salt Lake City" state="UT"/>
</cities>
</locations>
""")
Expand Down