[wwwsearch-commits] r27814 - in wwwsearch/mechanize/trunk: mechanize test
jjlee at codespeak.net
jjlee at codespeak.net
Mon May 29 00:39:37 CEST 2006
Author: jjlee
Date: Mon May 29 00:39:35 2006
New Revision: 27814
Added:
wwwsearch/mechanize/trunk/mechanize/_response.py
Modified:
wwwsearch/mechanize/trunk/mechanize/__init__.py
wwwsearch/mechanize/trunk/mechanize/_gzip.py
wwwsearch/mechanize/trunk/mechanize/_mechanize.py
wwwsearch/mechanize/trunk/mechanize/_urllib2_support.py
wwwsearch/mechanize/trunk/mechanize/_util.py
wwwsearch/mechanize/trunk/test/test_mechanize.py
wwwsearch/mechanize/trunk/test/test_misc.py
Log:
Split out response stuff from _util.py
Modified: wwwsearch/mechanize/trunk/mechanize/__init__.py
==============================================================================
--- wwwsearch/mechanize/trunk/mechanize/__init__.py (original)
+++ wwwsearch/mechanize/trunk/mechanize/__init__.py Mon May 29 00:39:35 2006
@@ -18,7 +18,7 @@
# misc
from _util import http2time as str2time
-from _util import response_seek_wrapper, make_response
+from _response import response_seek_wrapper, make_response
from _urllib2_support import HeadParser
try:
from _urllib2_support import XHTMLCompatibleHeadParser
Modified: wwwsearch/mechanize/trunk/mechanize/_gzip.py
==============================================================================
--- wwwsearch/mechanize/trunk/mechanize/_gzip.py (original)
+++ wwwsearch/mechanize/trunk/mechanize/_gzip.py Mon May 29 00:39:35 2006
@@ -1,6 +1,6 @@
import urllib2
from cStringIO import StringIO
-import _util
+import _response
# GzipConsumer was taken from Fredrik Lundh's effbot.org-0.1-20041009 library
class GzipConsumer:
@@ -65,7 +65,7 @@
def __init__(self): self.data = []
def feed(self, data): self.data.append(data)
-class stupid_gzip_wrapper(_util.closeable_response):
+class stupid_gzip_wrapper(_response.closeable_response):
def __init__(self, response):
self._response = response
Modified: wwwsearch/mechanize/trunk/mechanize/_mechanize.py
==============================================================================
--- wwwsearch/mechanize/trunk/mechanize/_mechanize.py (original)
+++ wwwsearch/mechanize/trunk/mechanize/_mechanize.py Mon May 29 00:39:35 2006
@@ -13,7 +13,7 @@
from _useragent import UserAgent
from _html import DefaultFactory
-from _util import response_seek_wrapper, closeable_response
+from _response import response_seek_wrapper, closeable_response
import _request
__version__ = (0, 1, 3, None, None) # 0.1.3
Added: wwwsearch/mechanize/trunk/mechanize/_response.py
==============================================================================
--- (empty file)
+++ wwwsearch/mechanize/trunk/mechanize/_response.py Mon May 29 00:39:35 2006
@@ -0,0 +1,344 @@
+"""(Mostly HTTP) response classes.
+
+Copyright 2006 John J. Lee <jjl at pobox.com>
+
+This code is free software; you can redistribute it and/or modify it
+under the terms of the BSD or ZPL 2.1 licenses (see the file COPYING.txt
+included with the distribution).
+
+"""
+
+import copy, mimetools
+from cStringIO import StringIO
+
+# XXX Andrew Dalke kindly sent me a similar class in response to my request on
+# comp.lang.python, which I then proceeded to lose. I wrote this class
+# instead, but I think he's released his code publicly since, could pinch the
+# tests from it, at least...
+
+# For testing seek_wrapper invariant (note that
+# test_urllib2.HandlerTest.test_seekable is expected to fail when this
+# invariant checking is turned on). The invariant checking is done by module
+# ipdc, which is available here:
+# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/436834
+## from ipdbc import ContractBase
+## class seek_wrapper(ContractBase):
+class seek_wrapper:
+ """Adds a seek method to a file object.
+
+ This is only designed for seeking on readonly file-like objects.
+
+ Wrapped file-like object must have a read method. The readline method is
+ only supported if that method is present on the wrapped object. The
+ readlines method is always supported. xreadlines and iteration are
+ supported only for Python 2.2 and above.
+
+ Public attribute: wrapped (the wrapped file object).
+
+ WARNING: All other attributes of the wrapped object (ie. those that are not
+ one of wrapped, read, readline, readlines, xreadlines, __iter__ and next)
+ are passed through unaltered, which may or may not make sense for your
+ particular file object.
+
+ """
+ # General strategy is to check that cache is full enough, then delegate to
+ # the cache (self.__cache, which is a cStringIO.StringIO instance). A seek
+ # position (self.__pos) is maintained independently of the cache, in order
+ # that a single cache may be shared between multiple seek_wrapper objects.
+ # Copying using module copy shares the cache in this way.
+
+ def __init__(self, wrapped):
+ self.wrapped = wrapped
+ self.__have_readline = hasattr(self.wrapped, "readline")
+ self.__cache = StringIO()
+ self.__pos = 0 # seek position
+
+ def invariant(self):
+ # The end of the cache is always at the same place as the end of the
+ # wrapped file.
+ return self.wrapped.tell() == len(self.__cache.getvalue())
+
+ def __getattr__(self, name):
+ wrapped = self.__dict__.get("wrapped")
+ if wrapped:
+ return getattr(wrapped, name)
+ return getattr(self.__class__, name)
+
+ def seek(self, offset, whence=0):
+ assert whence in [0,1,2]
+
+ # how much data, if any, do we need to read?
+ if whence == 2: # 2: relative to end of *wrapped* file
+ if offset < 0: raise ValueError("negative seek offset")
+ # since we don't know yet where the end of that file is, we must
+ # read everything
+ to_read = None
+ else:
+ if whence == 0: # 0: absolute
+ if offset < 0: raise ValueError("negative seek offset")
+ dest = offset
+ else: # 1: relative to current position
+ pos = self.__pos
+ if pos < offset:
+ raise ValueError("seek to before start of file")
+ dest = pos + offset
+ end = len(self.__cache.getvalue())
+ to_read = dest - end
+ if to_read < 0:
+ to_read = 0
+
+ if to_read != 0:
+ self.__cache.seek(0, 2)
+ if to_read is None:
+ assert whence == 2
+ self.__cache.write(self.wrapped.read())
+ self.__pos = self.__cache.tell() - offset
+ else:
+ self.__cache.write(self.wrapped.read(to_read))
+ # Don't raise an exception even if we've seek()ed past the end
+ # of .wrapped, since fseek() doesn't complain in that case.
+ # Also like fseek(), pretend we have seek()ed past the end,
+ # i.e. not:
+ #self.__pos = self.__cache.tell()
+ # but rather:
+ self.__pos = dest
+ else:
+ self.__pos = dest
+
+ def tell(self):
+ return self.__pos
+
+ def __copy__(self):
+ cpy = self.__class__(self.wrapped)
+ cpy.__cache = self.__cache
+ return cpy
+
+ def get_data(self):
+ pos = self.__pos
+ try:
+ self.seek(0)
+ return self.read(-1)
+ finally:
+ self.__pos = pos
+
+ def read(self, size=-1):
+ pos = self.__pos
+ end = len(self.__cache.getvalue())
+ available = end - pos
+
+ # enough data already cached?
+ if size <= available and size != -1:
+ self.__cache.seek(pos)
+ self.__pos = pos+size
+ return self.__cache.read(size)
+
+ # no, so read sufficient data from wrapped file and cache it
+ self.__cache.seek(0, 2)
+ if size == -1:
+ self.__cache.write(self.wrapped.read())
+ else:
+ to_read = size - available
+ assert to_read > 0
+ self.__cache.write(self.wrapped.read(to_read))
+ self.__cache.seek(pos)
+
+ data = self.__cache.read(size)
+ self.__pos = self.__cache.tell()
+ assert self.__pos == pos + len(data)
+ return data
+
+ def readline(self, size=-1):
+ if not self.__have_readline:
+ raise NotImplementedError("no readline method on wrapped object")
+
+ # line we're about to read might not be complete in the cache, so
+ # read another line first
+ pos = self.__pos
+ self.__cache.seek(0, 2)
+ self.__cache.write(self.wrapped.readline())
+ self.__cache.seek(pos)
+
+ data = self.__cache.readline()
+ if size != -1:
+ r = data[:size]
+ self.__pos = pos+size
+ else:
+ r = data
+ self.__pos = pos+len(data)
+ return r
+
+ def readlines(self, sizehint=-1):
+ pos = self.__pos
+ self.__cache.seek(0, 2)
+ self.__cache.write(self.wrapped.read())
+ self.__cache.seek(pos)
+ data = self.__cache.readlines(sizehint)
+ self.__pos = self.__cache.tell()
+ return data
+
+ def __iter__(self): return self
+ def next(self):
+ line = self.readline()
+ if line == "": raise StopIteration
+ return line
+
+ xreadlines = __iter__
+
+ def __repr__(self):
+ return ("<%s at %s whose wrapped object = %r>" %
+ (self.__class__.__name__, hex(id(self)), self.wrapped))
+
+
+class response_seek_wrapper(seek_wrapper):
+
+ """
+ Supports copying response objects and setting response body data.
+
+ """
+
+ def __init__(self, wrapped):
+ seek_wrapper.__init__(self, wrapped)
+ self._headers = self.wrapped.info()
+
+ def __copy__(self):
+ cpy = seek_wrapper.__copy__(self)
+ # copy headers from delegate
+ cpy._headers = copy.copy(self.info())
+ return cpy
+
+ def info(self):
+ return self._headers
+
+ def set_data(self, data):
+ self.seek(0)
+ self.read()
+ self.close()
+ cache = self._seek_wrapper__cache = StringIO()
+ cache.write(data)
+ self.seek(0)
+
+
+class eoffile:
+ # file-like object that always claims to be at end-of-file...
+ def read(self, size=-1): return ""
+ def readline(self, size=-1): return ""
+ def __iter__(self): return self
+ def next(self): return ""
+ def close(self): pass
+
+class eofresponse(eoffile):
+ def __init__(self, url, headers, code, msg):
+ self._url = url
+ self._headers = headers
+ self.code = code
+ self.msg = msg
+ def geturl(self): return self._url
+ def info(self): return self._headers
+
+
+class closeable_response:
+ """Avoids unnecessarily clobbering urllib.addinfourl methods on .close().
+
+ Only supports responses returned by mechanize.HTTPHandler.
+
+ After .close(), the following methods are supported:
+
+ .read()
+ .readline()
+ .readlines()
+ .seek()
+ .tell()
+ .info()
+ .geturl()
+ .__iter__()
+ .next()
+ .close()
+
+ and the following attributes are supported:
+
+ .code
+ .msg
+
+ Also supports pickling (but the stdlib currently does something to prevent
+ it: http://python.org/sf/1144636).
+
+ """
+ # presence of this attr indicates is useable after .close()
+ closeable_response = None
+
+ def __init__(self, fp, headers, url, code, msg):
+ self._set_fp(fp)
+ self._headers = headers
+ self._url = url
+ self.code = code
+ self.msg = msg
+
+ def _set_fp(self, fp):
+ self.fp = fp
+ self.read = self.fp.read
+ self.readline = self.fp.readline
+ if hasattr(self.fp, "readlines"): self.readlines = self.fp.readlines
+ if hasattr(self.fp, "fileno"):
+ self.fileno = self.fp.fileno
+ else:
+ self.fileno = lambda: None
+ if hasattr(self.fp, "__iter__"):
+ self.__iter__ = self.fp.__iter__
+ if hasattr(self.fp, "next"):
+ self.next = self.fp.next
+
+ def __repr__(self):
+ return '<%s at %s whose fp = %r>' % (
+ self.__class__.__name__, hex(id(self)), self.fp)
+
+ def info(self):
+ return self._headers
+
+ def geturl(self):
+ return self._url
+
+ def close(self):
+ wrapped = self.fp
+ wrapped.close()
+ new_wrapped = eofresponse(
+ self._url, self._headers, self.code, self.msg)
+ self._set_fp(new_wrapped)
+
+ def __getstate__(self):
+ # There are three obvious options here:
+ # 1. truncate
+ # 2. read to end
+ # 3. close socket, pickle state including read position, then open
+ # again on unpickle and use Range header
+ # XXXX um, 4. refuse to pickle unless .close()d. This is better,
+ # actually ("errors should never pass silently"). Pickling doesn't
+ # work anyway ATM, because of http://python.org/sf/1144636 so fix
+ # this later
+
+ # 2 breaks pickle protocol, because one expects the original object
+ # to be left unscathed by pickling. 3 is too complicated and
+ # surprising (and too much work ;-) to happen in a sane __getstate__.
+ # So we do 1.
+
+ state = self.__dict__.copy()
+ new_wrapped = eofresponse(
+ self._url, self._headers, self.code, self.msg)
+ state["wrapped"] = new_wrapped
+ return state
+
+def make_response(data, headers, url, code, msg):
+ """Convenient factory for objects implementing response interface.
+
+ data: string containing response body data
+ headers: sequence of (name, value) pairs
+ url: URL of response
+ code: integer response code (e.g. 200)
+ msg: string response code message (e.g. "OK")
+
+ """
+ hdr_text = []
+ for name_value in headers:
+ hdr_text.append("%s: %s" % name_value)
+ mime_headers = mimetools.Message(StringIO("\n".join(hdr_text)))
+ r = closeable_response(StringIO(data), mime_headers, url, code, msg)
+ return response_seek_wrapper(r)
Modified: wwwsearch/mechanize/trunk/mechanize/_urllib2_support.py
==============================================================================
--- wwwsearch/mechanize/trunk/mechanize/_urllib2_support.py (original)
+++ wwwsearch/mechanize/trunk/mechanize/_urllib2_support.py Mon May 29 00:39:35 2006
@@ -22,7 +22,8 @@
import _opener
from _request import Request
-from _util import isstringlike, closeable_response, response_seek_wrapper
+from _util import isstringlike
+from _response import closeable_response, response_seek_wrapper
from _html import unescape, unescape_charref
from _headersutil import is_html
from _clientcookie import CookieJar, request_host
Modified: wwwsearch/mechanize/trunk/mechanize/_util.py
==============================================================================
--- wwwsearch/mechanize/trunk/mechanize/_util.py (original)
+++ wwwsearch/mechanize/trunk/mechanize/_util.py Mon May 29 00:39:35 2006
@@ -8,9 +8,7 @@
"""
-import re, string, time, copy, urllib, mimetools
-from types import TupleType
-from cStringIO import StringIO
+import re, string, time
def isstringlike(x):
try: x+""
@@ -280,336 +278,3 @@
return None # bad format
return _str2time(day, mon, yr, hr, min, sec, tz)
-
-
-# XXX Andrew Dalke kindly sent me a similar class in response to my request on
-# comp.lang.python, which I then proceeded to lose. I wrote this class
-# instead, but I think he's released his code publicly since, could pinch the
-# tests from it, at least...
-
-# For testing seek_wrapper invariant (note that
-# test_urllib2.HandlerTest.test_seekable is expected to fail when this
-# invariant checking is turned on). The invariant checking is done by module
-# ipdc, which is available here:
-# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/436834
-## from ipdbc import ContractBase
-## class seek_wrapper(ContractBase):
-class seek_wrapper:
- """Adds a seek method to a file object.
-
- This is only designed for seeking on readonly file-like objects.
-
- Wrapped file-like object must have a read method. The readline method is
- only supported if that method is present on the wrapped object. The
- readlines method is always supported. xreadlines and iteration are
- supported only for Python 2.2 and above.
-
- Public attribute: wrapped (the wrapped file object).
-
- WARNING: All other attributes of the wrapped object (ie. those that are not
- one of wrapped, read, readline, readlines, xreadlines, __iter__ and next)
- are passed through unaltered, which may or may not make sense for your
- particular file object.
-
- """
- # General strategy is to check that cache is full enough, then delegate to
- # the cache (self.__cache, which is a cStringIO.StringIO instance). A seek
- # position (self.__pos) is maintained independently of the cache, in order
- # that a single cache may be shared between multiple seek_wrapper objects.
- # Copying using module copy shares the cache in this way.
-
- def __init__(self, wrapped):
- self.wrapped = wrapped
- self.__have_readline = hasattr(self.wrapped, "readline")
- self.__cache = StringIO()
- self.__pos = 0 # seek position
-
- def invariant(self):
- # The end of the cache is always at the same place as the end of the
- # wrapped file.
- return self.wrapped.tell() == len(self.__cache.getvalue())
-
- def __getattr__(self, name):
- wrapped = self.__dict__.get("wrapped")
- if wrapped:
- return getattr(wrapped, name)
- return getattr(self.__class__, name)
-
- def seek(self, offset, whence=0):
- assert whence in [0,1,2]
-
- # how much data, if any, do we need to read?
- if whence == 2: # 2: relative to end of *wrapped* file
- if offset < 0: raise ValueError("negative seek offset")
- # since we don't know yet where the end of that file is, we must
- # read everything
- to_read = None
- else:
- if whence == 0: # 0: absolute
- if offset < 0: raise ValueError("negative seek offset")
- dest = offset
- else: # 1: relative to current position
- pos = self.__pos
- if pos < offset:
- raise ValueError("seek to before start of file")
- dest = pos + offset
- end = len(self.__cache.getvalue())
- to_read = dest - end
- if to_read < 0:
- to_read = 0
-
- if to_read != 0:
- self.__cache.seek(0, 2)
- if to_read is None:
- assert whence == 2
- self.__cache.write(self.wrapped.read())
- self.__pos = self.__cache.tell() - offset
- else:
- self.__cache.write(self.wrapped.read(to_read))
- # Don't raise an exception even if we've seek()ed past the end
- # of .wrapped, since fseek() doesn't complain in that case.
- # Also like fseek(), pretend we have seek()ed past the end,
- # i.e. not:
- #self.__pos = self.__cache.tell()
- # but rather:
- self.__pos = dest
- else:
- self.__pos = dest
-
- def tell(self):
- return self.__pos
-
- def __copy__(self):
- cpy = self.__class__(self.wrapped)
- cpy.__cache = self.__cache
- return cpy
-
- def get_data(self):
- pos = self.__pos
- try:
- self.seek(0)
- return self.read(-1)
- finally:
- self.__pos = pos
-
- def read(self, size=-1):
- pos = self.__pos
- end = len(self.__cache.getvalue())
- available = end - pos
-
- # enough data already cached?
- if size <= available and size != -1:
- self.__cache.seek(pos)
- self.__pos = pos+size
- return self.__cache.read(size)
-
- # no, so read sufficient data from wrapped file and cache it
- self.__cache.seek(0, 2)
- if size == -1:
- self.__cache.write(self.wrapped.read())
- else:
- to_read = size - available
- assert to_read > 0
- self.__cache.write(self.wrapped.read(to_read))
- self.__cache.seek(pos)
-
- data = self.__cache.read(size)
- self.__pos = self.__cache.tell()
- assert self.__pos == pos + len(data)
- return data
-
- def readline(self, size=-1):
- if not self.__have_readline:
- raise NotImplementedError("no readline method on wrapped object")
-
- # line we're about to read might not be complete in the cache, so
- # read another line first
- pos = self.__pos
- self.__cache.seek(0, 2)
- self.__cache.write(self.wrapped.readline())
- self.__cache.seek(pos)
-
- data = self.__cache.readline()
- if size != -1:
- r = data[:size]
- self.__pos = pos+size
- else:
- r = data
- self.__pos = pos+len(data)
- return r
-
- def readlines(self, sizehint=-1):
- pos = self.__pos
- self.__cache.seek(0, 2)
- self.__cache.write(self.wrapped.read())
- self.__cache.seek(pos)
- data = self.__cache.readlines(sizehint)
- self.__pos = self.__cache.tell()
- return data
-
- def __iter__(self): return self
- def next(self):
- line = self.readline()
- if line == "": raise StopIteration
- return line
-
- xreadlines = __iter__
-
- def __repr__(self):
- return ("<%s at %s whose wrapped object = %r>" %
- (self.__class__.__name__, hex(id(self)), self.wrapped))
-
-
-class response_seek_wrapper(seek_wrapper):
-
- """
- Supports copying response objects and setting response body data.
-
- """
-
- def __init__(self, wrapped):
- seek_wrapper.__init__(self, wrapped)
- self._headers = self.wrapped.info()
-
- def __copy__(self):
- cpy = seek_wrapper.__copy__(self)
- # copy headers from delegate
- cpy._headers = copy.copy(self.info())
- return cpy
-
- def info(self):
- return self._headers
-
- def set_data(self, data):
- self.seek(0)
- self.read()
- self.close()
- cache = self._seek_wrapper__cache = StringIO()
- cache.write(data)
- self.seek(0)
-
-
-class eoffile:
- # file-like object that always claims to be at end-of-file...
- def read(self, size=-1): return ""
- def readline(self, size=-1): return ""
- def __iter__(self): return self
- def next(self): return ""
- def close(self): pass
-
-class eofresponse(eoffile):
- def __init__(self, url, headers, code, msg):
- self._url = url
- self._headers = headers
- self.code = code
- self.msg = msg
- def geturl(self): return self._url
- def info(self): return self._headers
-
-
-class closeable_response:
- """Avoids unnecessarily clobbering urllib.addinfourl methods on .close().
-
- Only supports responses returned by mechanize.HTTPHandler.
-
- After .close(), the following methods are supported:
-
- .read()
- .readline()
- .readlines()
- .seek()
- .tell()
- .info()
- .geturl()
- .__iter__()
- .next()
- .close()
-
- and the following attributes are supported:
-
- .code
- .msg
-
- Also supports pickling (but the stdlib currently does something to prevent
- it: http://python.org/sf/1144636).
-
- """
- # presence of this attr indicates is useable after .close()
- closeable_response = None
-
- def __init__(self, fp, headers, url, code, msg):
- self._set_fp(fp)
- self._headers = headers
- self._url = url
- self.code = code
- self.msg = msg
-
- def _set_fp(self, fp):
- self.fp = fp
- self.read = self.fp.read
- self.readline = self.fp.readline
- if hasattr(self.fp, "readlines"): self.readlines = self.fp.readlines
- if hasattr(self.fp, "fileno"):
- self.fileno = self.fp.fileno
- else:
- self.fileno = lambda: None
- if hasattr(self.fp, "__iter__"):
- self.__iter__ = self.fp.__iter__
- if hasattr(self.fp, "next"):
- self.next = self.fp.next
-
- def __repr__(self):
- return '<%s at %s whose fp = %r>' % (
- self.__class__.__name__, hex(id(self)), self.fp)
-
- def info(self):
- return self._headers
-
- def geturl(self):
- return self._url
-
- def close(self):
- wrapped = self.fp
- wrapped.close()
- new_wrapped = eofresponse(
- self._url, self._headers, self.code, self.msg)
- self._set_fp(new_wrapped)
-
- def __getstate__(self):
- # There are three obvious options here:
- # 1. truncate
- # 2. read to end
- # 3. close socket, pickle state including read position, then open
- # again on unpickle and use Range header
- # XXXX um, 4. refuse to pickle unless .close()d. This is better,
- # actually ("errors should never pass silently"). Pickling doesn't
- # work anyway ATM, because of http://python.org/sf/1144636 so fix
- # this later
-
- # 2 breaks pickle protocol, because one expects the original object
- # to be left unscathed by pickling. 3 is too complicated and
- # surprising (and too much work ;-) to happen in a sane __getstate__.
- # So we do 1.
-
- state = self.__dict__.copy()
- new_wrapped = eofresponse(
- self._url, self._headers, self.code, self.msg)
- state["wrapped"] = new_wrapped
- return state
-
-def make_response(data, headers, url, code, msg):
- """Convenient factory for objects implementing response interface.
-
- data: string containing response body data
- headers: sequence of (name, value) pairs
- url: URL of response
- code: integer response code (e.g. 200)
- msg: string response code message (e.g. "OK")
-
- """
- hdr_text = []
- for name_value in headers:
- hdr_text.append("%s: %s" % name_value)
- mime_headers = mimetools.Message(StringIO("\n".join(hdr_text)))
- r = closeable_response(StringIO(data), mime_headers, url, code, msg)
- return response_seek_wrapper(r)
Modified: wwwsearch/mechanize/trunk/test/test_mechanize.py
==============================================================================
--- wwwsearch/mechanize/trunk/test/test_mechanize.py (original)
+++ wwwsearch/mechanize/trunk/test/test_mechanize.py Mon May 29 00:39:35 2006
@@ -668,7 +668,7 @@
def test_str(self):
import mimetools
- from mechanize import _util
+ from mechanize import _response
br = TestBrowser()
self.assertEqual(
@@ -679,7 +679,8 @@
fp = StringIO.StringIO('<html><form name="f"><input /></form></html>')
headers = mimetools.Message(
StringIO.StringIO("Content-type: text/html"))
- response = _util.response_seek_wrapper(_util.closeable_response(
+ response = _response.response_seek_wrapper(
+ _response.closeable_response(
fp, headers, "http://example.com/", 200, "OK"))
br.set_response(response)
self.assertEqual(
Modified: wwwsearch/mechanize/trunk/test/test_misc.py
==============================================================================
--- wwwsearch/mechanize/trunk/test/test_misc.py (original)
+++ wwwsearch/mechanize/trunk/test/test_misc.py Mon May 29 00:39:35 2006
@@ -55,7 +55,7 @@
text_lines = map(lambda l: l+"\n", text.split("\n")[:-1])
def testSeekable(self):
- from mechanize._util import seek_wrapper
+ from mechanize._response import seek_wrapper
text = self.text
text_lines = self.text_lines
More information about the wwwsearch-commits
mailing list