[Checkins] SVN: z3c.dav/trunk/src/z3c/dav/ Fix up tests to work
with lxml.
Michael Kerrin
michael.kerrin at openapp.ie
Tue Jul 3 15:22:42 EDT 2007
Log message for revision 77377:
Fix up tests to work with lxml.
Changed:
U z3c.dav/trunk/src/z3c/dav/locking.py
U z3c.dav/trunk/src/z3c/dav/testing.py
U z3c.dav/trunk/src/z3c/dav/utils.py
-=-
Modified: z3c.dav/trunk/src/z3c/dav/locking.py
===================================================================
--- z3c.dav/trunk/src/z3c/dav/locking.py 2007-07-03 19:07:52 UTC (rev 77376)
+++ z3c.dav/trunk/src/z3c/dav/locking.py 2007-07-03 19:22:42 UTC (rev 77377)
@@ -39,6 +39,7 @@
"""
__docformat__ = 'restructuredtext'
+import copy
import time
import random
import datetime
@@ -339,7 +340,7 @@
owner = xmlsource.find("{DAV:}owner")
if owner is not None: # The owner element is optional.
- owner_str = etree.tostring(owner)
+ owner_str = etree.tostring(copy.copy(owner))
else:
owner_str = None
Modified: z3c.dav/trunk/src/z3c/dav/testing.py
===================================================================
--- z3c.dav/trunk/src/z3c/dav/testing.py 2007-07-03 19:07:52 UTC (rev 77376)
+++ z3c.dav/trunk/src/z3c/dav/testing.py 2007-07-03 19:22:42 UTC (rev 77377)
@@ -42,6 +42,7 @@
information out of a 207 Multi-Status response. The idea is to make
writing tests for different WebDAV components a lot easier.
+ >>> import copy
>>> from zope.publisher.http import HTTPResponse
>>> etree = z3c.etree.getEngine()
@@ -88,7 +89,7 @@
>>> msresponses = wrapped.getMSResponses()
>>> len(msresponses)
1
- >>> print etree.tostring(msresponses[0]) #doctest:+XMLDATA
+ >>> print etree.tostring(copy.copy(msresponses[0])) #doctest:+XMLDATA
<response xmlns="DAV:" />
Now use the `getMSResponse(href)` to get a response element who's href
@@ -107,7 +108,8 @@
>>> wrapped._body = None # turn off cache
>>> print etree.tostring(
- ... wrapped.getMSResponse('/testfile.txt')) #doctest:+XMLDATA
+ ... copy.copy(
+ ... wrapped.getMSResponse('/testfile.txt'))) #doctest:+XMLDATA
<response xmlns="DAV:">
<href>/testfile.txt</href>
</response>
@@ -165,7 +167,8 @@
KeyError: 'No propstats element with status 200'
>>> print etree.tostring(
- ... wrapped.getMSPropstat('/testfile.txt', 404)) #doctest:+XMLDATA
+ ... copy.copy(
+ ... wrapped.getMSPropstat('/testfile.txt', 404))) #doctest:+XMLDATA
<propstat xmlns="DAV:">
<status>HTTP/1.1 404 Not Found</status>
</propstat>
Modified: z3c.dav/trunk/src/z3c/dav/utils.py
===================================================================
--- z3c.dav/trunk/src/z3c/dav/utils.py 2007-07-03 19:07:52 UTC (rev 77376)
+++ z3c.dav/trunk/src/z3c/dav/utils.py 2007-07-03 19:22:42 UTC (rev 77377)
@@ -185,12 +185,15 @@
>>> parseEtreeTag('{DAV:}prop')
['DAV:', 'prop']
+ >>> parseEtreeTag('{}prop')
+ ['', 'prop']
+
>>> parseEtreeTag('prop')
(None, 'prop')
"""
- if tag[0] == '{':
- return tag[1:].split('}')
+ if tag[0] == "{":
+ return tag[1:].split("}")
return None, tag
################################################################################
More information about the Checkins
mailing list