From 072b1195e245011fa508343b1f9b8ab4738f87d2 Mon Sep 17 00:00:00 2001 From: leogregianin Date: Fri, 14 May 2021 09:18:01 -0400 Subject: [PATCH] Add more namespace attribute tests --- tests/test_xmltodict.py | 46 ++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/tests/test_xmltodict.py b/tests/test_xmltodict.py index 0455d96..04137f9 100644 --- a/tests/test_xmltodict.py +++ b/tests/test_xmltodict.py @@ -183,7 +183,8 @@ def test_namespace_support(self): xml = """ + xmlns:b="http://b.com/" + version="1.00"> 1 2 3 @@ -191,12 +192,13 @@ def test_namespace_support(self): """ 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', }, @@ -211,7 +213,8 @@ def test_namespace_collapse(self): xml = """ + xmlns:b="http://b.com/" + version="1.00"> 1 2 3 @@ -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', }, @@ -243,7 +247,8 @@ def test_namespace_collapse_all(self): xml = """ + xmlns:b="http://b.com/" + version="1.00"> 1 2 3 @@ -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', }, @@ -272,7 +278,8 @@ def test_namespace_ignore(self): xml = """ + xmlns:b="http://b.com/" + version="1.00"> 1 2 3 @@ -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',