[Zope3-checkins] SVN: Zope3/trunk/src/zope/ fix a bug in
zope.testbrowser: it was being inconsistent between the handling
Benji York
benji at zope.com
Tue Nov 8 10:04:37 EST 2005
Log message for revision 39975:
fix a bug in zope.testbrowser: it was being inconsistent between the handling
of responses from the Zope 3 publisher and responses from external sites
Changed:
U Zope3/trunk/src/zope/app/apidoc/browser/README.txt
U Zope3/trunk/src/zope/testbrowser/browser.py
U Zope3/trunk/src/zope/testbrowser/over_the_wire.txt
U Zope3/trunk/src/zope/testbrowser/testing.py
-=-
Modified: Zope3/trunk/src/zope/app/apidoc/browser/README.txt
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/browser/README.txt 2005-11-08 14:38:13 UTC (rev 39974)
+++ Zope3/trunk/src/zope/app/apidoc/browser/README.txt 2005-11-08 15:04:36 UTC (rev 39975)
@@ -27,10 +27,7 @@
... pass
>>> print error.read()
- Status: 404 Not Found
- Content-Length: ...
- Content-Type: text/html;charset=utf-8
- ...
+ <...
<h1 class="details-header">
Page Not Found
</h1>
Modified: Zope3/trunk/src/zope/testbrowser/browser.py
===================================================================
--- Zope3/trunk/src/zope/testbrowser/browser.py 2005-11-08 14:38:13 UTC (rev 39974)
+++ Zope3/trunk/src/zope/testbrowser/browser.py 2005-11-08 15:04:36 UTC (rev 39975)
@@ -171,8 +171,6 @@
response = self.mech_browser.response()
old_location = response.tell()
response.seek(0)
- for line in iter(lambda: response.readline().strip(), ''):
- pass
self._contents = response.read()
response.seek(old_location)
return self._contents
Modified: Zope3/trunk/src/zope/testbrowser/over_the_wire.txt
===================================================================
--- Zope3/trunk/src/zope/testbrowser/over_the_wire.txt 2005-11-08 14:38:13 UTC (rev 39974)
+++ Zope3/trunk/src/zope/testbrowser/over_the_wire.txt 2005-11-08 15:04:36 UTC (rev 39975)
@@ -21,6 +21,8 @@
>>> browser.open('http://google.com/ncr')
>>> browser.url
'http://www.google.com/'
+ >>> 'html' in browser.contents.lower()
+ True
We'll put some text in the query box...
Modified: Zope3/trunk/src/zope/testbrowser/testing.py
===================================================================
--- Zope3/trunk/src/zope/testbrowser/testing.py 2005-11-08 14:38:13 UTC (rev 39974)
+++ Zope3/trunk/src/zope/testbrowser/testing.py 2005-11-08 15:04:36 UTC (rev 39975)
@@ -81,25 +81,21 @@
headers = real_response.getHeaders()
headers.sort()
- output = (
- "Status: %s\r\n%s\r\n\r\n%s" % (
- real_response.getStatusString(),
- '\r\n'.join([('%s: %s' % h) for h in headers]),
- real_response.consumeBody(),
- )
- )
- return PublisherResponse(output, status, reason)
+ headers.insert(0, ('Status', real_response.getStatusString()))
+ headers = '\r\n'.join('%s: %s' % h for h in headers)
+ content = real_response.consumeBody()
+ return PublisherResponse(content, headers, status, reason)
class PublisherResponse(object):
"""``urllib2`` compatible response object."""
- def __init__(self, content, status, reason):
+ def __init__(self, content, headers, status, reason):
self.content = content
self.status = status
self.reason = reason
- self.msg = httplib.HTTPMessage(StringIO(content), 0)
- self.content_as_file = StringIO(content)
+ self.msg = httplib.HTTPMessage(StringIO(headers), 0)
+ self.content_as_file = StringIO(self.content)
def read(self, amt=None):
return self.content_as_file.read(amt)
More information about the Zope3-Checkins
mailing list