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 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
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.confirm(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