Skip to content

Commit 1739e87

Browse files
committed
bpo-42151: add ElementTree test for default attribute values
1 parent f7a3bd1 commit 1739e87

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Lib/test/test_xml_etree.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,19 @@
108108
<document>&entity;</document>
109109
"""
110110

111+
ATTLIST_XML = """\
112+
<?xml version="1.0" encoding="UTF-8"?>
113+
<!DOCTYPE Foo [
114+
<!ELEMENT foo (bar*)>
115+
<!ELEMENT bar (#PCDATA)*>
116+
<!ATTLIST bar xml:lang CDATA "eng">
117+
<!ENTITY qux "quux">
118+
]>
119+
<foo>
120+
<bar>&qux;</bar>
121+
</foo>
122+
"""
123+
111124
def checkwarnings(*filters, quiet=False):
112125
def decorator(test):
113126
def newtest(*args, **kwargs):
@@ -1354,6 +1367,12 @@ def test_tree_write_attribute_order(self):
13541367
self.assertEqual(serialize(root, method='html'),
13551368
'<cirriculum status="public" company="example"></cirriculum>')
13561369

1370+
def test_attlist_default(self):
1371+
# Test default attribute values; See BPO 42151.
1372+
root = ET.fromstring(ATTLIST_XML)
1373+
self.assertEqual(root[0].attrib,
1374+
{'{http://www.w3.org/XML/1998/namespace}lang': 'eng'})
1375+
13571376

13581377
class XMLPullParserTest(unittest.TestCase):
13591378

0 commit comments

Comments
 (0)