From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Sat, 26 Apr 2025 20:28:00 +0000 (+0200) Subject: [3.13] gh-63882: Implement some `test_minidom` tests (GH-132879) (#133029) X-Git-Tag: v3.13.4~215 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fdcaaad1cc7cee1bc23097d9493c2c1cdd9f404e;p=thirdparty%2FPython%2Fcpython.git [3.13] gh-63882: Implement some `test_minidom` tests (GH-132879) (#133029) Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com> Co-authored-by: Julian Gindi 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> --- diff --git a/Lib/test/test_minidom.py b/Lib/test/test_minidom.py index f717fd03ca56..6679c0a4fbed 100644 --- a/Lib/test/test_minidom.py +++ b/Lib/test/test_minidom.py @@ -396,13 +396,28 @@ class MinidomTest(unittest.TestCase): dom.unlink() def testGetAttrList(self): - pass + dom = parseString("") + 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("") + 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 @@ class MinidomTest(unittest.TestCase): self.assertEqual(str(node), repr(node)) dom.unlink() - def testTextNodeRepr(self): pass - def testWriteXML(self): str = '' dom = parseString(str) @@ -601,9 +614,19 @@ class MinidomTest(unittest.TestCase): and pi.localName is None and pi.namespaceURI == xml.dom.EMPTY_NAMESPACE) - def testProcessingInstructionRepr(self): pass + def testProcessingInstructionRepr(self): + dom = parseString('') + 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('', str(el)) def testWriteText(self): pass