https://github.com/python/cpython/commit/fdcaaad1cc7cee1bc23097d9493c2c1cdd9f404e commit: fdcaaad1cc7cee1bc23097d9493c2c1cdd9f404e branch: 3.13 author: Miss Islington (bot) <31488909+miss-isling...@users.noreply.github.com> committer: hugovk <1324225+hug...@users.noreply.github.com> date: 2025-04-26T20:28:00Z summary:
[3.13] gh-63882: Implement some `test_minidom` tests (GH-132879) (#133029) Co-authored-by: Stan Ulbrych <89152624+stanfromirel...@users.noreply.github.com> Co-authored-by: Julian Gindi <jul...@gindi.io> Co-authored-by: Hugo van Kemenade <1324225+hug...@users.noreply.github.com> Co-authored-by: Bénédikt Tran <10796600+picn...@users.noreply.github.com> files: M Lib/test/test_minidom.py diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py index f717fd03ca5662..6679c0a4fbedd9 100644 --- a/Lib/test/test_minidom.py +++ b/Lib/test/test_minidom.py @@ -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() @@ -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) @@ -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 _______________________________________________ Python-checkins mailing list -- python-checkins@python.org To unsubscribe send an email to python-checkins-le...@python.org https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: arch...@mail-archive.com