Commit 1aff7695 authored by Jérome Perrin's avatar Jérome Perrin

core_text: drop dependency on PyXML

use sax.xml API which gives us the first parser available, instead of
using a specific parser that happens to come from pyxml
parent 54a448f6
...@@ -29,8 +29,9 @@ ...@@ -29,8 +29,9 @@
import unittest import unittest
import pickle import pickle
import re import re
import xml.parsers.pyexpat import xml.sax
from StringIO import StringIO from StringIO import StringIO
from Products.ERP5Type.XMLExportImport import ppml from Products.ERP5Type.XMLExportImport import ppml
...@@ -67,12 +68,11 @@ class TestXMLPickle(unittest.TestCase): ...@@ -67,12 +68,11 @@ class TestXMLPickle(unittest.TestCase):
F.file = output F.file = output
F.binary = 1 F.binary = 1
p=xml.parsers.pyexpat.ParserCreate() content_handler = xml.sax.handler.ContentHandler()
p.CharacterDataHandler=F.handle_data content_handler.startElement = F.unknown_starttag
p.StartElementHandler=F.unknown_starttag content_handler.endElement = F.unknown_endtag
p.EndElementHandler=F.unknown_endtag content_handler.characters = F.handle_data
xml.sax.parseString(xmldata, content_handler)
p.Parse(xmldata)
reconstructed_pickled_data = F._stack[0][0] reconstructed_pickled_data = F._stack[0][0]
reconstructed_obj = pickle.loads(reconstructed_pickled_data) reconstructed_obj = pickle.loads(reconstructed_pickled_data)
...@@ -84,6 +84,3 @@ class TestXMLPickle(unittest.TestCase): ...@@ -84,6 +84,3 @@ class TestXMLPickle(unittest.TestCase):
self.assert_(reconstructed_obj.data[2] is reconstructed_obj.data) self.assert_(reconstructed_obj.data[2] is reconstructed_obj.data)
self.assert_(type(reconstructed_obj.data[3]) is type(pattern)) self.assert_(type(reconstructed_obj.data[3]) is type(pattern))
self.assertEqual(reconstructed_obj.data[3].pattern, 'WAA') self.assertEqual(reconstructed_obj.data[3].pattern, 'WAA')
if __name__ == '__main__':
unittest.main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment