Skip to content

Commit

Permalink
Add more namespace attribute tests
Browse files Browse the repository at this point in the history
  • Loading branch information
leogregianin authored and martinblech committed May 8, 2022
1 parent f2e6d31 commit 072b119
Showing 1 changed file with 27 additions and 19 deletions.
46 changes: 27 additions & 19 deletions tests/test_xmltodict.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,20 +183,22 @@ def test_namespace_support(self):
xml = """
<root xmlns="http://defaultns.com/"
xmlns:a="http://a.com/"
xmlns:b="http://b.com/">
xmlns:b="http://b.com/"
version="1.00">
<x a:attr="val">1</x>
<a:y>2</a:y>
<b:z>3</b:z>
</root>
"""
d = {
'http://defaultns.com/:root': {
'@version': '1.00',
'@xmlns': {
'': 'http://defaultns.com/',
'a': 'http://a.com/',
'b': 'http://b.com/',
},
'http://defaultns.com/:x': {
'@xmlns': {
'': 'http://defaultns.com/',
'a': 'http://a.com/',
'b': 'http://b.com/',
},
'@http://a.com/:attr': 'val',
'#text': '1',
},
Expand All @@ -211,7 +213,8 @@ def test_namespace_collapse(self):
xml = """
<root xmlns="http://defaultns.com/"
xmlns:a="http://a.com/"
xmlns:b="http://b.com/">
xmlns:b="http://b.com/"
version="1.00">
<x a:attr="val">1</x>
<a:y>2</a:y>
<b:z>3</b:z>
Expand All @@ -223,12 +226,13 @@ def test_namespace_collapse(self):
}
d = {
'root': {
'@version': '1.00',
'@xmlns': {
'': 'http://defaultns.com/',
'a': 'http://a.com/',
'b': 'http://b.com/',
},
'x': {
'@xmlns': {
'': 'http://defaultns.com/',
'a': 'http://a.com/',
'b': 'http://b.com/',
},
'@ns_a:attr': 'val',
'#text': '1',
},
Expand All @@ -243,7 +247,8 @@ def test_namespace_collapse_all(self):
xml = """
<root xmlns="http://defaultns.com/"
xmlns:a="http://a.com/"
xmlns:b="http://b.com/">
xmlns:b="http://b.com/"
version="1.00">
<x a:attr="val">1</x>
<a:y>2</a:y>
<b:z>3</b:z>
Expand All @@ -252,12 +257,13 @@ def test_namespace_collapse_all(self):
namespaces = collections.defaultdict(lambda: None)
d = {
'root': {
'@version': '1.00',
'@xmlns': {
'': 'http://defaultns.com/',
'a': 'http://a.com/',
'b': 'http://b.com/',
},
'x': {
'@xmlns': {
'': 'http://defaultns.com/',
'a': 'http://a.com/',
'b': 'http://b.com/',
},
'@attr': 'val',
'#text': '1',
},
Expand All @@ -272,7 +278,8 @@ def test_namespace_ignore(self):
xml = """
<root xmlns="http://defaultns.com/"
xmlns:a="http://a.com/"
xmlns:b="http://b.com/">
xmlns:b="http://b.com/"
version="1.00">
<x>1</x>
<a:y>2</a:y>
<b:z>3</b:z>
Expand All @@ -283,6 +290,7 @@ def test_namespace_ignore(self):
'@xmlns': 'http://defaultns.com/',
'@xmlns:a': 'http://a.com/',
'@xmlns:b': 'http://b.com/',
'@version': '1.00',
'x': '1',
'a:y': '2',
'b:z': '3',
Expand Down

0 comments on commit 072b119

Please sign in to comment.