[Checkins] SVN: z3c.etestbrowser/trunk/src/z3c/etestbrowser/ added
option to strictly use the xml parser instead of html for the etree.
Christian Zagrodnick
cz at gocept.com
Fri May 18 10:27:57 EDT 2007
Log message for revision 75828:
added option to strictly use the xml parser instead of html for the etree.
Changed:
U z3c.etestbrowser/trunk/src/z3c/etestbrowser/README.txt
U z3c.etestbrowser/trunk/src/z3c/etestbrowser/testing.py
-=-
Modified: z3c.etestbrowser/trunk/src/z3c/etestbrowser/README.txt
===================================================================
--- z3c.etestbrowser/trunk/src/z3c/etestbrowser/README.txt 2007-05-18 14:27:08 UTC (rev 75827)
+++ z3c.etestbrowser/trunk/src/z3c/etestbrowser/README.txt 2007-05-18 14:27:56 UTC (rev 75828)
@@ -6,11 +6,13 @@
for extensions that have dependencies that we do not want to rely on in the
Zope 3 core e.g. lxml.
+
Requirements
============
- lxml
+
EtreeTestBrowser
================
@@ -30,6 +32,22 @@
...
</html>
>>> browser.etree
- <etree._ElementTree object at 0x...>
- >>> browser.etree.xpath('//html')
- [<Element html at ...>]
+ <Element html at ...>
+ >>> browser.etree.xpath('//body')
+ [<Element body at ...>]
+
+
+Strict XML
+==========
+
+It is possible to force the test browser to use the xml parser::
+
+ >>> browser.xml_strict
+ False
+ >>> browser.xml_strict = True
+ >>> browser.open("http://localhost/")
+ >>> browser.etree
+ <Element {http://www.w3.org/1999/xhtml}html at ...>
+ >>> browser.etree.xpath(
+ ... '//html:body', {'html': 'http://www.w3.org/1999/xhtml'})
+ [<Element {http://www.w3.org/1999/xhtml}body at ...>]
Modified: z3c.etestbrowser/trunk/src/z3c/etestbrowser/testing.py
===================================================================
--- z3c.etestbrowser/trunk/src/z3c/etestbrowser/testing.py 2007-05-18 14:27:08 UTC (rev 75827)
+++ z3c.etestbrowser/trunk/src/z3c/etestbrowser/testing.py 2007-05-18 14:27:56 UTC (rev 75828)
@@ -34,6 +34,8 @@
"""
+ xml_strict = False
+
_etree = None
@property
@@ -42,8 +44,11 @@
return self._etree
# I'm not using any internal knowledge about testbrowser
# here, to avoid breakage. Memory usage won't be a problem.
- content = StringIO.StringIO(self.contents)
- self._etree = lxml.etree.parse(content, html_parser)
+ if self.xml_strict:
+ parser = None
+ else:
+ parser = html_parser
+ self._etree = lxml.etree.XML(self.contents, parser)
return self._etree
def _changed(self):
More information about the Checkins
mailing list