[Lxml-checkins] r46642 - in lxml/trunk/src/lxml: . tests

scoder at codespeak.net scoder at codespeak.net
Sat Sep 15 17:29:26 CEST 2007


Author: scoder
Date: Sat Sep 15 17:29:26 2007
New Revision: 46642

Modified:
   lxml/trunk/src/lxml/etree.pyx
   lxml/trunk/src/lxml/tests/test_elementtree.py
Log:
ET 1.3 compat: getchildren() will go away, findall() might return an iterator (or maybe not)

Modified: lxml/trunk/src/lxml/etree.pyx
==============================================================================
--- lxml/trunk/src/lxml/etree.pyx	(original)
+++ lxml/trunk/src/lxml/etree.pyx	Sat Sep 15 17:29:26 2007
@@ -976,13 +976,12 @@
         """
         cdef xmlNode* c_node
         cdef int ret
-# ET 1.3 stops supporting this ...
-##         import warnings
-##         warnings.warn(
-##             "This method will be removed in future versions. "
-##             "Use 'list(elem)' or iteration over elem instead.",
-##             DeprecationWarning
-##             )
+        import warnings
+        warnings.warn(
+            "This method will be removed in future versions. "
+            "Use 'list(elem)' or iteration over elem instead.",
+            DeprecationWarning
+            )
         result = []
         c_node = self._c_node.children
         while c_node is not NULL:

Modified: lxml/trunk/src/lxml/tests/test_elementtree.py
==============================================================================
--- lxml/trunk/src/lxml/tests/test_elementtree.py	(original)
+++ lxml/trunk/src/lxml/tests/test_elementtree.py	Sat Sep 15 17:29:26 2007
@@ -650,19 +650,19 @@
     def test_findall(self):
         XML = self.etree.XML
         root = XML('<a><b><c/></b><b/><c><b/></c></a>')
-        self.assertEquals(len(root.findall("c")), 1)
-        self.assertEquals(len(root.findall(".//c")), 2)
-        self.assertEquals(len(root.findall(".//b")), 3)
-        self.assertEquals(len(root.findall(".//b")[0]), 1)
-        self.assertEquals(len(root.findall(".//b")[1]), 0)
-        self.assertEquals(len(root.findall(".//b")[2]), 0)
+        self.assertEquals(len(list(root.findall("c"))), 1)
+        self.assertEquals(len(list(root.findall(".//c"))), 2)
+        self.assertEquals(len(list(root.findall(".//b"))), 3)
+        self.assertEquals(len(list(root.findall(".//b"))[0]), 1)
+        self.assertEquals(len(list(root.findall(".//b"))[1]), 0)
+        self.assertEquals(len(list(root.findall(".//b"))[2]), 0)
 
     def test_findall_ns(self):
         XML = self.etree.XML
         root = XML('<a xmlns:x="X" xmlns:y="Y"><x:b><c/></x:b><b/><c><x:b/><b/></c><b/></a>')
-        self.assertEquals(len(root.findall(".//{X}b")), 2)
-        self.assertEquals(len(root.findall(".//b")), 3)
-        self.assertEquals(len(root.findall("b")), 2)
+        self.assertEquals(len(list(root.findall(".//{X}b"))), 2)
+        self.assertEquals(len(list(root.findall(".//b"))), 3)
+        self.assertEquals(len(list(root.findall("b"))), 2)
 
     def test_element_with_attributes_keywords(self):
         Element = self.etree.Element
@@ -1385,8 +1385,8 @@
             '<a></a>',
             a)
         self.assertEquals('b2', b.tail)
-        
-    def test_getchildren(self):
+
+    def _test_getchildren(self):
         Element = self.etree.Element
         SubElement = self.etree.SubElement
 


More information about the lxml-checkins mailing list