]> granicus.if.org Git - python/commitdiff
Backport minidom attribute tests from default (73c76466cf44).
authorÉric Araujo <merwok@netwok.org>
Mon, 5 Mar 2012 15:11:41 +0000 (16:11 +0100)
committerÉric Araujo <merwok@netwok.org>
Mon, 5 Mar 2012 15:11:41 +0000 (16:11 +0100)
Some minidom code changed between 3.2 and 3.3, so to be sure to avoid
differenced in behavior I’m backporting these tests added by MvL.

Lib/test/test_minidom.py

index f3fa1b8c5815c65985c377a1d366e9957d75ed24..4a69b00153981195b84b7fe59c811bc2b531c619 100644 (file)
@@ -350,13 +350,31 @@ class MinidomTest(unittest.TestCase):
     def testGetAttrList(self):
         pass
 
-    def testGetAttrValues(self): pass
+    def testGetAttrValues(self):
+        pass
 
-    def testGetAttrLength(self): pass
+    def testGetAttrLength(self):
+        pass
 
-    def testGetAttribute(self): pass
+    def testGetAttribute(self):
+        dom = Document()
+        child = dom.appendChild(
+            dom.createElementNS("http://www.python.org", "python:abc"))
+        self.assertEqual(child.getAttribute('missing'), '')
 
-    def testGetAttributeNS(self): pass
+    def testGetAttributeNS(self):
+        dom = Document()
+        child = dom.appendChild(
+                dom.createElementNS("http://www.python.org", "python:abc"))
+        child.setAttributeNS("http://www.w3.org", "xmlns:python",
+                                                "http://www.python.org")
+        self.assertEqual(child.getAttributeNS("http://www.w3.org", "python"),
+            'http://www.python.org')
+        self.assertEqual(child.getAttributeNS("http://www.w3.org", "other"),
+            '')
+        child2 = child.appendChild(dom.createElement('abc'))
+        self.assertEqual(child2.getAttributeNS("http://www.python.org", "missing"),
+                         '')
 
     def testGetAttributeNode(self): pass