]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-63882: Implement some `test_minidom` tests (GH-132879) (#133029)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sat, 26 Apr 2025 20:28:00 +0000 (22:28 +0200)
committerGitHub <noreply@github.com>
Sat, 26 Apr 2025 20:28:00 +0000 (20:28 +0000)
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>
Lib/test/test_minidom.py

index f717fd03ca5662976bc12b35f77edcde9deb28cc..6679c0a4fbedd9fad46338103241fb2d67a2b7ea 100644 (file)
@@ -396,13 +396,28 @@ class MinidomTest(unittest.TestCase):
         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 @@ class MinidomTest(unittest.TestCase):
         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 @@ 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('<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