Skip to content

gh-63882: Implement some test_minidom tests #132879

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

Merged
merged 6 commits into from
Apr 26, 2025
Merged
Changes from 2 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
43 changes: 34 additions & 9 deletions Lib/test/test_minidom.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,14 +395,27 @@ def testChangeAttr(self):
and el.getAttribute("spam2") == "bam2")
dom.unlink()

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

def testGetAttrValues(self):
pass

def testGetAttrLength(self):
pass
dom = parseString("<abc/>")
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)
dom.unlink()

def testGetAttribute(self):
dom = Document()
Expand Down Expand Up @@ -496,7 +509,11 @@ def testAttributeRepr(self):
self.confirm(str(node) == repr(node))
dom.unlink()

def testTextNodeRepr(self): pass
def testTextNodeRepr(self):
dom = Document()
el = dom.appendChild(dom.createElement("foo"))
self.confirm(str(el) == repr(el))
dom.unlink()

def testWriteXML(self):
str = '<?xml version="1.0" ?><a b="c"/>'
Expand Down Expand Up @@ -601,9 +618,17 @@ 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()
elem = dom.createElement('elem')
elem.appendChild(dom.createTextNode("foo"))
el = elem.firstChild
self.assertEqual(str(el), repr(el))

def testWriteText(self): pass

Expand Down
Loading