Skip to content
Merged
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
gh-63882: Implement some test_minidom tests (GH-132879)
(cherry picked from commit ee033d4)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Co-authored-by: Julian Gindi <julian@gindi.io>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
  • Loading branch information
4 people authored and miss-islington committed Apr 26, 2025
commit 0496125cf1402cc5105754ff04c6b3e5e4ebd0fd
41 changes: 32 additions & 9 deletions Lib/test/test_minidom.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,13 +396,28 @@ def testChangeAttr(self):
dom.unlink()

def testGetAttrList(self):
pass
dom = parseString("<abc/>")
self.addCleanup(dom.unlink)
el = dom.documentElement
el.setAttribute("spam", "jam")
self.assertEqual(len(el.attributes.items()), 1)
el.setAttribute("foo", "bar")
items = el.attributes.items()
self.assertEqual(len(items), 2)
self.assertIn(('spam', 'jam'), items)
self.assertIn(('foo', 'bar'), items)

def testGetAttrValues(self):
pass

def testGetAttrLength(self):
pass
dom = parseString("<abc/>")
self.addCleanup(dom.unlink)
el = dom.documentElement
el.setAttribute("spam", "jam")
values = [x.value for x in el.attributes.values()]
self.assertIn("jam", values)
el.setAttribute("foo", "bar")
values = [x.value for x in el.attributes.values()]
self.assertIn("bar", values)
self.assertIn("jam", values)

def testGetAttribute(self):
dom = Document()
Expand Down Expand Up @@ -496,8 +511,6 @@ def testAttributeRepr(self):
self.assertEqual(str(node), repr(node))
dom.unlink()

def testTextNodeRepr(self): pass

def testWriteXML(self):
str = '<?xml version="1.0" ?><a b="c"/>'
dom = parseString(str)
Expand Down Expand Up @@ -601,9 +614,19 @@ def testProcessingInstruction(self):
and pi.localName is None
and pi.namespaceURI == xml.dom.EMPTY_NAMESPACE)

def testProcessingInstructionRepr(self): pass
def testProcessingInstructionRepr(self):
dom = parseString('<e><?mypi \t\n data \t\n ?></e>')
pi = dom.documentElement.firstChild
self.assertEqual(str(pi.nodeType), repr(pi.nodeType))

def testTextRepr(self): pass
def testTextRepr(self):
dom = Document()
self.addCleanup(dom.unlink)
elem = dom.createElement("elem")
elem.appendChild(dom.createTextNode("foo"))
el = elem.firstChild
self.assertEqual(str(el), repr(el))
self.assertEqual('<DOM Text node "\'foo\'">', str(el))

def testWriteText(self): pass

Expand Down
Loading