[Erp5-report] r31603 nicolas - /erp5/trunk/products/ERP5Form/tests/testOOoChart.py

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Jan 6 15:48:09 CET 2010


Author: nicolas
Date: Wed Jan  6 15:48:08 2010
New Revision: 31603

URL: http://svn.erp5.org?rev=31603&view=rev
Log:
Replace libxml2 library by lxml

Modified:
    erp5/trunk/products/ERP5Form/tests/testOOoChart.py

Modified: erp5/trunk/products/ERP5Form/tests/testOOoChart.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Form/tests/testOOoChart.py?rev=31603&r1=31602&r2=31603&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Form/tests/testOOoChart.py [utf8] (original)
+++ erp5/trunk/products/ERP5Form/tests/testOOoChart.py [utf8] Wed Jan  6 15:48:08 2010
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 ##############################################################################
 # Copyright (c) 2008 Nexedi SA and Contributors. All Rights Reserved.
 #          Deheunynck Thibaut <thibaut at nexedi.com>
@@ -38,6 +39,7 @@
 from Products.ERP5Type.Globals import get_request
 from Products.ERP5OOo.Document.OOoDocument import STANDARD_IMAGE_FORMAT_LIST
 from Products.ERP5Type.Core.Folder import Folder
+from lxml import etree
 
 HTTP_OK = 200
 debug = 0
@@ -157,20 +159,20 @@
       parser = OOoParser()
       parser.openFromString(body)
       content_xml_view = parser.oo_files['content.xml']
-      import libxml2
-      doc_view = libxml2.parseDoc(content_xml_view)
+
+      doc_view = etree.fromstring(content_xml_view)
       xpath = '//@*[name() = "xlink:href"]'
-      num_object = doc_view.xpathEval(xpath)[0].content[2:]
+      num_object = doc_view.xpath(xpath)[0][2:]
 
       content_xml_build = parser.oo_files['%s/content.xml' % num_object]
-      doc_build = libxml2.parseDoc(content_xml_build)
+      doc_build = etree.fromstring(content_xml_build)
       xpath = '//@*[name() = "office:value"]'
-      values = doc_build.xpathEval(xpath)
+      value_list = doc_build.xpath(xpath)
       # Test the data presence in the file XML
-      self.assertNotEquals(0, len(values))
+      self.assertNotEquals(0, len(value_list))
       # 2 values because there are - 10 document created by a owner 
       #                            - 0 Reference count
-      self.assertEquals(2, len(values))
+      self.assertEquals(2, len(value_list))
 
       # Test the differents render
       # render image
@@ -250,20 +252,20 @@
       parser = OOoParser()
       parser.openFromString(body)
       content_xml_view = parser.oo_files['content.xml']
-      import libxml2
-      doc_view = libxml2.parseDoc(content_xml_view)
+
+      doc_view = etree.fromstring(content_xml_view)
       xpath = '//@*[name() = "xlink:href"]'
-      num_object = doc_view.xpathEval(xpath)[0].content[2:]
+      num_object = doc_view.xpath(xpath)[0][2:]
 
       content_xml_build = parser.oo_files['%s/content.xml' % num_object]
-      doc_build = libxml2.parseDoc(content_xml_build)
+      doc_build = etree.fromstring(content_xml_build)
       xpath = '//@*[name() = "office:value"]'
-      values = doc_build.xpathEval(xpath)
+      value_list = doc_build.xpath(xpath)
       # Test the data presence in the file XML
-      self.assertNotEquals(0, len(values))
+      self.assertNotEquals(0, len(value_list))
       # 2 values because there are - 10 document created by a owner 
       #                            - 0 Reference count
-      self.assertEquals(2, len(values))
+      self.assertEquals(2, len(value_list))
 
       # Test the differents render
       # render image




More information about the Erp5-report mailing list