[wwwsearch-commits] r26865 - in wwwsearch/mechanize/trunk: mechanize test

jjlee at codespeak.net jjlee at codespeak.net
Sat May 6 14:09:51 CEST 2006


Author: jjlee
Date: Sat May  6 14:09:50 2006
New Revision: 26865

Modified:
   wwwsearch/mechanize/trunk/mechanize/__init__.py
   wwwsearch/mechanize/trunk/test/test_conncache.py
   wwwsearch/mechanize/trunk/test/test_cookies.py
   wwwsearch/mechanize/trunk/test/test_date.py
   wwwsearch/mechanize/trunk/test/test_headers.py
   wwwsearch/mechanize/trunk/test/test_misc.py
   wwwsearch/mechanize/trunk/test/test_urllib2.py
Log:
Oops, didn't update imports of ClientCookie in tests on ClientCookie / pullparser merge branch that got merged to trunk just a few minutes ago (forgot to move ClientCookie off sys.path when testing)!  This fixes that.

Modified: wwwsearch/mechanize/trunk/mechanize/__init__.py
==============================================================================
--- wwwsearch/mechanize/trunk/mechanize/__init__.py	(original)
+++ wwwsearch/mechanize/trunk/mechanize/__init__.py	Sat May  6 14:09:50 2006
@@ -27,7 +27,7 @@
     from _urllib2_support import XHTMLCompatibleHeadParser
 except ImportError:
     pass
-from ClientCookie._urllib2_support import \
+from _urllib2_support import \
      HTTPHandler, HTTPRedirectHandler, \
      HTTPRequestUpgradeProcessor, \
      HTTPEquivProcessor, SeekableProcessor, HTTPCookieProcessor, \
@@ -38,7 +38,7 @@
 
 import httplib
 if hasattr(httplib, 'HTTPS'):
-    from ClientCookie._urllib2_support import HTTPSHandler
+    from _urllib2_support import HTTPSHandler
 del httplib
 
 from _Util import http2time as str2time

Modified: wwwsearch/mechanize/trunk/test/test_conncache.py
==============================================================================
--- wwwsearch/mechanize/trunk/test/test_conncache.py	(original)
+++ wwwsearch/mechanize/trunk/test/test_conncache.py	Sat May  6 14:09:50 2006
@@ -1,11 +1,11 @@
-"""Tests for ClientCookie._ConnCache module."""
+"""Tests for mechanize._ConnCache module."""
 
 import unittest, sys
 
 class ConnCacheTests(unittest.TestCase):
 
     def test_ConnectionCache(self):
-        from ClientCookie import ConnectionCache
+        from mechanize import ConnectionCache
         ConnectionCache()
 
 

Modified: wwwsearch/mechanize/trunk/test/test_cookies.py
==============================================================================
--- wwwsearch/mechanize/trunk/test/test_cookies.py	(original)
+++ wwwsearch/mechanize/trunk/test/test_cookies.py	Sat May  6 14:09:50 2006
@@ -1,15 +1,10 @@
-"""Tests for ClientCookie._ClientCookie."""
+"""Tests for _ClientCookie."""
 
 import urllib2, re, os, string, StringIO, mimetools, time
 from time import localtime
 from unittest import TestCase
 
-from ClientCookie._Util import startswith
-
-try: True
-except NameError:
-    True = 1
-    False = 0
+from mechanize._Util import startswith
 
 class FakeResponse:
     def __init__(self, headers=[], url=None):
@@ -30,7 +25,7 @@
 
 def _interact(cookiejar, url, set_cookie_hdrs, hdr_name):
     """Perform a single request / response cycle, returning Cookie: header."""
-    from ClientCookie import Request
+    from mechanize import Request
     req = Request(url)
     cookiejar.add_cookie_header(req)
     cookie_hdr = req.get_header("Cookie", "")
@@ -95,8 +90,8 @@
         # may require disk access -- in particular, with MSIECookieJar)
         # This is only a rough check for performance reasons, so it's not too
         # critical as long as it's sufficiently liberal.
-        import ClientCookie
-        pol = ClientCookie.DefaultCookiePolicy()
+        import mechanize
+        pol = mechanize.DefaultCookiePolicy()
         for url, domain, ok in [
             ("http://foo.bar.com/", "blah.com", False),
             ("http://foo.bar.com/", "rhubarb.blah.com", False),
@@ -115,13 +110,13 @@
             ("http://foo/", "foo.local", True),
             ("http://foo/", ".local", True),
             ]:
-            request = ClientCookie.Request(url)
+            request = mechanize.Request(url)
             r = pol.domain_return_ok(domain, request)
             if ok: self.assert_(r)
             else: self.assert_(not r)
 
     def test_missing_name(self):
-        from ClientCookie import MozillaCookieJar, lwp_cookie_str
+        from mechanize import MozillaCookieJar, lwp_cookie_str
 
         # missing = sign in Cookie: header is regarded by Mozilla as a missing
         # NAME.  WE regard it as a missing VALUE.
@@ -155,7 +150,7 @@
     def test_rfc2109_handling(self):
         # 2109 cookies have rfc2109 attr set correctly, and are handled
         # as 2965 or Netscape cookies depending on policy settings
-        from ClientCookie import CookieJar, DefaultCookiePolicy
+        from mechanize import CookieJar, DefaultCookiePolicy
 
         for policy, version in [
             (DefaultCookiePolicy(), 0),
@@ -170,8 +165,8 @@
             self.assertEqual(cookie.version, version)
 
     def test_ns_parser(self):
-        from ClientCookie import CookieJar
-        from ClientCookie._ClientCookie import DEFAULT_HTTP_PORT
+        from mechanize import CookieJar
+        from mechanize._ClientCookie import DEFAULT_HTTP_PORT
 
         c = CookieJar()
         interact_netscape(c, "http://www.acme.com/",
@@ -210,7 +205,7 @@
     def test_ns_parser_special_names(self):
         # names such as 'expires' are not special in first name=value pair
         # of Set-Cookie: header
-        from ClientCookie import CookieJar
+        from mechanize import CookieJar
 
         c = CookieJar()
         interact_netscape(c, "http://www.acme.com/", 'expires=eggs')
@@ -221,8 +216,8 @@
         self.assert_(cookies.has_key('version'))
 
     def test_expires(self):
-        from ClientCookie._Util import time2netscape
-        from ClientCookie import CookieJar
+        from mechanize._Util import time2netscape
+        from mechanize import CookieJar
 
         # if expires is in future, keep cookie...
         c = CookieJar()
@@ -262,7 +257,7 @@
         # XXX RFC 2965 expiry rules (some apply to V0 too)
 
     def test_default_path(self):
-        from ClientCookie import CookieJar, DefaultCookiePolicy
+        from mechanize import CookieJar, DefaultCookiePolicy
 
         # RFC 2965
         pol = DefaultCookiePolicy(rfc2965=True)
@@ -304,7 +299,7 @@
         assert c._cookies["www.acme.com"].has_key("/blah/rhubarb")
 
     def test_escape_path(self):
-        from ClientCookie._ClientCookie import escape_path
+        from mechanize._ClientCookie import escape_path
         cases = [
             # quoted safe
             ("/foo%2f/bar", "/foo%2F/bar"),
@@ -321,22 +316,15 @@
             # unquoted unsafe
             ("/foo\031/bar", "/foo%19/bar"),
             ("/\175foo/bar", "/%7Dfoo/bar"),
-            ]
-        try:
-            unicode
-        except NameError:
-            pass
-        else:
-            cases.append(
             # unicode
-            (u"/foo/bar\uabcd", "/foo/bar%EA%AF%8D")  # UTF-8 encoded
-            )
+            (u"/foo/bar\uabcd", "/foo/bar%EA%AF%8D"),  # UTF-8 encoded
+            ]
         for arg, result in cases:
             self.assert_(escape_path(arg) == result)
 
     def test_request_path(self):
         from urllib2 import Request
-        from ClientCookie._ClientCookie import request_path
+        from mechanize._ClientCookie import request_path
         # with parameters
         req = Request("http://www.example.com/rheum/rhaponicum;"
                       "foo=bar;sing=song?apples=pears&spam=eggs#ni")
@@ -353,7 +341,7 @@
 
     def test_request_port(self):
         from urllib2 import Request
-        from ClientCookie._ClientCookie import request_port, DEFAULT_HTTP_PORT
+        from mechanize._ClientCookie import request_port, DEFAULT_HTTP_PORT
         req = Request("http://www.acme.com:1234/",
                       headers={"Host": "www.acme.com:4321"})
         assert request_port(req) == "1234"
@@ -362,8 +350,8 @@
         assert request_port(req) == DEFAULT_HTTP_PORT
 
     def test_request_host(self):
-        from ClientCookie import Request
-        from ClientCookie._ClientCookie import request_host
+        from mechanize import Request
+        from mechanize._ClientCookie import request_host
         # this request is illegal (RFC2616, 14.2.3)
         req = Request("http://1.1.1.1/",
                       headers={"Host": "www.acme.com:80"})
@@ -385,7 +373,7 @@
         assert request_host(req) == "www.acme.com"
 
     def test_is_HDN(self):
-        from ClientCookie._ClientCookie import is_HDN
+        from mechanize._ClientCookie import is_HDN
         assert is_HDN("foo.bar.com")
         assert is_HDN("1foo2.3bar4.5com")
         assert not is_HDN("192.168.1.1")
@@ -396,7 +384,7 @@
         assert not is_HDN("foo.")
 
     def test_reach(self):
-        from ClientCookie._ClientCookie import reach
+        from mechanize._ClientCookie import reach
         assert reach("www.acme.com") == ".acme.com"
         assert reach("acme.com") == "acme.com"
         assert reach("acme.local") == ".local"
@@ -407,7 +395,7 @@
         assert reach("192.168.0.1") == "192.168.0.1"
 
     def test_domain_match(self):
-        from ClientCookie._ClientCookie import domain_match, user_domain_match
+        from mechanize._ClientCookie import domain_match, user_domain_match
         assert domain_match("192.168.1.1", "192.168.1.1")
         assert not domain_match("192.168.1.1", ".168.1.1")
         assert domain_match("x.y.com", "x.Y.com")
@@ -450,7 +438,7 @@
 
         """
         # XXX far from complete
-        from ClientCookie import CookieJar
+        from mechanize import CookieJar
         c = CookieJar()
         interact_2965(c, "http://www.nasty.com/", 'foo=bar; domain=friendly.org; Version="1"')
         assert len(c) == 0
@@ -458,7 +446,7 @@
     def test_strict_domain(self):
         # Cookies whose domain is a country-code tld like .co.uk should
         # not be set if CookiePolicy.strict_domain is true.
-        from ClientCookie import CookieJar, DefaultCookiePolicy
+        from mechanize import CookieJar, DefaultCookiePolicy
 
         cp = DefaultCookiePolicy(strict_domain=True)
         cj = CookieJar(policy=cp)
@@ -477,7 +465,7 @@
         # Netscape: .www.bar.com, www.bar.com, .bar.com, bar.com, no domain should
         #  all get accepted, as should .acme.com, acme.com and no domain for
         #  2-component domains like acme.com.
-        from ClientCookie import CookieJar, DefaultCookiePolicy
+        from mechanize import CookieJar, DefaultCookiePolicy
 
         c = CookieJar()
 
@@ -521,7 +509,7 @@
         assert len(c) == 4
 
     def test_two_component_domain_rfc2965(self):
-        from ClientCookie import CookieJar, DefaultCookiePolicy
+        from mechanize import CookieJar, DefaultCookiePolicy
 
         pol = DefaultCookiePolicy(rfc2965=True)
         c = CookieJar(pol)
@@ -563,8 +551,8 @@
         assert len(c) == 3
 
     def test_domain_allow(self):
-        from ClientCookie import CookieJar, DefaultCookiePolicy
-        from ClientCookie import Request
+        from mechanize import CookieJar, DefaultCookiePolicy
+        from mechanize import Request
 
         c = CookieJar(policy=DefaultCookiePolicy(
             blocked_domains=["acme.com"],
@@ -597,10 +585,10 @@
         assert not req.has_header("Cookie")
 
     def test_domain_block(self):
-        from ClientCookie import CookieJar, DefaultCookiePolicy
-        from ClientCookie import Request
+        from mechanize import CookieJar, DefaultCookiePolicy
+        from mechanize import Request
 
-        #import logging; logging.getLogger("ClientCookie").setLevel(logging.DEBUG)
+        #import logging; logging.getLogger("mechanize").setLevel(logging.DEBUG)
 
         pol = DefaultCookiePolicy(
             rfc2965=True, blocked_domains=[".acme.com"])
@@ -642,7 +630,7 @@
         assert not req.has_header("Cookie")
 
     def test_secure(self):
-        from ClientCookie import CookieJar, DefaultCookiePolicy
+        from mechanize import CookieJar, DefaultCookiePolicy
 
         for ns in True, False:
             for whitespace in " ", "":
@@ -665,7 +653,7 @@
                        "secure cookie registered non-secure"
 
     def test_quote_cookie_value(self):
-        from ClientCookie import CookieJar, DefaultCookiePolicy
+        from mechanize import CookieJar, DefaultCookiePolicy
         c = CookieJar(policy=DefaultCookiePolicy(rfc2965=True))
         interact_2965(c, "http://www.acme.com/", r'foo=\b"a"r; Version=1')
         h = interact_2965(c, "http://www.acme.com/")
@@ -673,7 +661,7 @@
 
     def test_missing_final_slash(self):
         # Missing slash from request URL's abs_path should be assumed present.
-        from ClientCookie import CookieJar, Request, DefaultCookiePolicy
+        from mechanize import CookieJar, Request, DefaultCookiePolicy
         url = "http://www.acme.com"
         c = CookieJar(DefaultCookiePolicy(rfc2965=True))
         interact_2965(c, url, "foo=bar; Version=1")
@@ -683,7 +671,7 @@
         assert req.has_header("Cookie")
 
     def test_domain_mirror(self):
-        from ClientCookie import CookieJar, DefaultCookiePolicy
+        from mechanize import CookieJar, DefaultCookiePolicy
 
         pol = DefaultCookiePolicy(rfc2965=True)
 
@@ -710,7 +698,7 @@
                "domain not returned"
 
     def test_path_mirror(self):
-        from ClientCookie import CookieJar, DefaultCookiePolicy
+        from mechanize import CookieJar, DefaultCookiePolicy
 
         pol = DefaultCookiePolicy(rfc2965=True)
 
@@ -728,7 +716,7 @@
         assert string.find(h, '$Path="/"') != -1, "path not returned"
 
     def test_port_mirror(self):
-        from ClientCookie import CookieJar, DefaultCookiePolicy
+        from mechanize import CookieJar, DefaultCookiePolicy
 
         pol = DefaultCookiePolicy(rfc2965=True)
 
@@ -761,7 +749,7 @@
                "port with multiple values not returned with multiple values"
 
     def test_no_return_comment(self):
-        from ClientCookie import CookieJar, DefaultCookiePolicy
+        from mechanize import CookieJar, DefaultCookiePolicy
 
         c = CookieJar(DefaultCookiePolicy(rfc2965=True))
         url = "http://foo.bar.com/"
@@ -774,7 +762,7 @@
 
 # just pondering security here -- this isn't really a test (yet)
 ##     def test_hack(self):
-##         from ClientCookie import CookieJar
+##         from mechanize import CookieJar
 
 ##         c = CookieJar()
 ##         interact_netscape(c, "http://victim.mall.com/",
@@ -787,7 +775,7 @@
 ##         print h
 
     def test_Cookie_iterator(self):
-        from ClientCookie import CookieJar, Cookie, DefaultCookiePolicy
+        from mechanize import CookieJar, Cookie, DefaultCookiePolicy
 
         cs = CookieJar(DefaultCookiePolicy(rfc2965=True))
         # add some random cookies
@@ -833,7 +821,7 @@
         self.assertRaises(IndexError, lambda cs=cs : cs[1])
 
     def test_parse_ns_headers(self):
-        from ClientCookie._HeadersUtil import parse_ns_headers
+        from mechanize._HeadersUtil import parse_ns_headers
 
         # missing domain value (invalid cookie)
         assert parse_ns_headers(["foo=bar; path=/; domain"]) == [
@@ -851,7 +839,7 @@
     def test_bad_cookie_header(self):
 
         def cookiejar_from_cookie_headers(headers):
-            from ClientCookie import CookieJar, Request
+            from mechanize import CookieJar, Request
             c = CookieJar()
             req = Request("http://www.example.com/")
             r = FakeResponse(headers, "http://www.example.com/")
@@ -882,7 +870,7 @@
     # Tests taken from libwww-perl, with a few modifications.
 
     def test_netscape_example_1(self):
-        from ClientCookie import CookieJar, Request, DefaultCookiePolicy
+        from mechanize import CookieJar, Request, DefaultCookiePolicy
 
         #-------------------------------------------------------------------
         # First we check that it works for the original example at
@@ -977,7 +965,7 @@
                 startswith(h, "SHIPPING=FEDEX;"))
 
     def test_netscape_example_2(self):
-        from ClientCookie import CookieJar, Request
+        from mechanize import CookieJar, Request
 
         # Second Example transaction sequence:
         # 
@@ -1029,7 +1017,7 @@
                          req.get_header("Cookie"))
 
     def test_ietf_example_1(self):
-        from ClientCookie import CookieJar, DefaultCookiePolicy
+        from mechanize import CookieJar, DefaultCookiePolicy
         #-------------------------------------------------------------------
         # Then we test with the examples from draft-ietf-http-state-man-mec-03.txt
         #
@@ -1143,7 +1131,7 @@
         # contains all the cookies received so far.
 
     def test_ietf_example_2(self):
-        from ClientCookie import CookieJar, DefaultCookiePolicy
+        from mechanize import CookieJar, DefaultCookiePolicy
 
         # 5.2  Example 2
         # 
@@ -1199,7 +1187,7 @@
 
     def test_rejection(self):
         # Test rejection of Set-Cookie2 responses based on domain, path, port.
-        from ClientCookie import LWPCookieJar, DefaultCookiePolicy
+        from mechanize import LWPCookieJar, DefaultCookiePolicy
 
         pol = DefaultCookiePolicy(rfc2965=True)
 
@@ -1293,7 +1281,7 @@
     def test_url_encoding(self):
         # Try some URL encodings of the PATHs.
         # (the behaviour here has changed from libwww-perl)
-        from ClientCookie import CookieJar, DefaultCookiePolicy
+        from mechanize import CookieJar, DefaultCookiePolicy
 
         c = CookieJar(DefaultCookiePolicy(rfc2965=True))
 
@@ -1316,7 +1304,7 @@
 
     def test_mozilla(self):
         # Save / load Mozilla/Netscape cookie file format.
-        from ClientCookie import MozillaCookieJar, DefaultCookiePolicy
+        from mechanize import MozillaCookieJar, DefaultCookiePolicy
 
         year_plus_one = localtime(time.time())[0] + 1
 
@@ -1339,7 +1327,7 @@
                           "fooc=bar; Domain=www.foo.com; %s" % expires)
 
         def save_and_restore(cj, ignore_discard, filename=filename):
-            from ClientCookie import MozillaCookieJar, DefaultCookiePolicy
+            from mechanize import MozillaCookieJar, DefaultCookiePolicy
             try:
                 cj.save(ignore_discard=ignore_discard)
                 new_c = MozillaCookieJar(filename,
@@ -1360,7 +1348,7 @@
 
     def test_netscape_misc(self):
         # Some additional Netscape cookies tests.
-        from ClientCookie import CookieJar, Request
+        from mechanize import CookieJar, Request
 
         c = CookieJar()
         headers = []
@@ -1387,7 +1375,7 @@
 
     def test_intranet_domains_2965(self):
         # Test handling of local intranet hostnames without a dot.
-        from ClientCookie import CookieJar, DefaultCookiePolicy
+        from mechanize import CookieJar, DefaultCookiePolicy
 
         c = CookieJar(DefaultCookiePolicy(rfc2965=True))
         interact_2965(c, "http://example/",
@@ -1401,7 +1389,7 @@
         assert string.find(cookie, "foo2=bar") >= 0 and len(c) == 3
 
     def test_intranet_domains_ns(self):
-        from ClientCookie import CookieJar, DefaultCookiePolicy
+        from mechanize import CookieJar, DefaultCookiePolicy
 
         c = CookieJar(DefaultCookiePolicy(rfc2965 = False))
         interact_netscape(c, "http://example/", "foo1=bar")
@@ -1414,7 +1402,7 @@
         assert string.find(cookie, "foo2=bar") >= 0 and len(c) == 2
 
     def test_empty_path(self):
-        from ClientCookie import CookieJar, Request, DefaultCookiePolicy
+        from mechanize import CookieJar, Request, DefaultCookiePolicy
 
         # Test for empty path
         # Broken web-server ORION/1.3.38 returns to the client response like
@@ -1447,7 +1435,7 @@
 # The correctness of this test is undefined, in the absence of RFC 2965 errata.
 ##     def test_netscape_rfc2965_interop(self):
 ##         # Test mixing of Set-Cookie and Set-Cookie2 headers.
-##         from ClientCookie import CookieJar
+##         from mechanize import CookieJar
 
 ##         # Example from http://www.trip.com/trs/trip/flighttracker/flight_tracker_home.xsl
 ##         # which gives up these headers:
@@ -1490,7 +1478,7 @@
 ##         """
 
     def test_session_cookies(self):
-        from ClientCookie import CookieJar, Request
+        from mechanize import CookieJar, Request
 
         year_plus_one = localtime(time.time())[0] + 1
 

Modified: wwwsearch/mechanize/trunk/test/test_date.py
==============================================================================
--- wwwsearch/mechanize/trunk/test/test_date.py	(original)
+++ wwwsearch/mechanize/trunk/test/test_date.py	Sat May  6 14:09:50 2006
@@ -3,15 +3,10 @@
 import re, string, time
 from unittest import TestCase
 
-try: True
-except NameError:
-    True = 1
-    False = 0
-
 class DateTimeTests(TestCase):
 
     def test_time2isoz(self):
-        from ClientCookie._Util import time2isoz
+        from mechanize._Util import time2isoz
 
         base = 1019227000
         day = 24*3600
@@ -27,7 +22,7 @@
                    "bad time2isoz format: %s %s" % (az, bz)
 
     def test_parse_date(self):
-        from ClientCookie._Util import http2time
+        from mechanize._Util import http2time
 
         def parse_date(text, http2time=http2time):
             return time.gmtime(http2time(text))[:6]
@@ -41,7 +36,7 @@
         assert parse_date("03-Feb-98") == (1998, 2, 3, 0, 0, 0.0)
 
     def test_http2time_formats(self):
-        from ClientCookie._Util import http2time, time2isoz
+        from mechanize._Util import http2time, time2isoz
 
         # test http2time for supported dates.  Test cases with 2 digit year
         # will probably break in year 2044.
@@ -80,7 +75,7 @@
                    "'%s'  =>  %s, %s, %s (%s)" % (s, t, t2, t3, test_t)
 
     def test_http2time_garbage(self):
-        from ClientCookie._Util import http2time
+        from mechanize._Util import http2time
 
         for test in [
             '', 'Garbage',

Modified: wwwsearch/mechanize/trunk/test/test_headers.py
==============================================================================
--- wwwsearch/mechanize/trunk/test/test_headers.py	(original)
+++ wwwsearch/mechanize/trunk/test/test_headers.py	Sat May  6 14:09:50 2006
@@ -2,14 +2,9 @@
 
 from unittest import TestCase
 
-try: True
-except NameError:
-    True = 1
-    False = 0
-
 class IsHtmlTests(TestCase):
     def test_is_html(self):
-        from ClientCookie._HeadersUtil import is_html
+        from mechanize._HeadersUtil import is_html
         for allow_xhtml in False, True:
             for cths, ext, expect in [
                 (["text/html"], ".html", True),
@@ -30,7 +25,7 @@
 
 class HeaderTests(TestCase):
     def test_parse_ns_headers(self):
-        from ClientCookie._HeadersUtil import parse_ns_headers
+        from mechanize._HeadersUtil import parse_ns_headers
 
         # quotes should be stripped
         assert parse_ns_headers(['foo=bar; expires=01 Jan 2040 22:23:32 GMT']) == \
@@ -41,7 +36,7 @@
     def test_parse_ns_headers_special_names(self):
         # names such as 'expires' are not special in first name=value pair
         # of Set-Cookie: header
-        from ClientCookie._HeadersUtil import parse_ns_headers
+        from mechanize._HeadersUtil import parse_ns_headers
 
         # Cookie with name 'expires'
         hdr = 'expires=01 Jan 2040 22:23:32 GMT'
@@ -49,7 +44,7 @@
         self.assertEquals(parse_ns_headers([hdr]), expected)
 
     def test_join_header_words(self):
-        from ClientCookie._HeadersUtil import join_header_words
+        from mechanize._HeadersUtil import join_header_words
 
         assert join_header_words([[
             ("foo", None), ("bar", "baz"), (None, "value")
@@ -58,7 +53,7 @@
         assert join_header_words([[]]) == ""
 
     def test_split_header_words(self):
-        from ClientCookie._HeadersUtil import split_header_words
+        from mechanize._HeadersUtil import split_header_words
 
         tests = [
             ("foo", [[("foo", None)]]),
@@ -94,7 +89,7 @@
 """ % (arg, expect, result)
 
     def test_roundtrip(self):
-        from ClientCookie._HeadersUtil import split_header_words, join_header_words
+        from mechanize._HeadersUtil import split_header_words, join_header_words
 
         tests = [
             ("foo", "foo"),

Modified: wwwsearch/mechanize/trunk/test/test_misc.py
==============================================================================
--- wwwsearch/mechanize/trunk/test/test_misc.py	(original)
+++ wwwsearch/mechanize/trunk/test/test_misc.py	Sat May  6 14:09:50 2006
@@ -4,11 +4,6 @@
 import cStringIO, string
 from unittest import TestCase
 
-try:
-    StopIteration
-except NameError:
-    from ClientCookie._ClientCookie import StopIteration
-
 class TestUnSeekable:
     def __init__(self, text):
         self._file = cStringIO.StringIO(text)
@@ -60,7 +55,7 @@
     text_lines = map(lambda l: l+"\n", string.split(text, "\n")[:-1])
 
     def testSeekable(self):
-        from ClientCookie._Util import seek_wrapper
+        from mechanize._Util import seek_wrapper
         text = self.text
         text_lines = self.text_lines
 
@@ -168,7 +163,7 @@
         self.assertEqual(sfh.read(), text)
 
     def testResponseSeekWrapper(self):
-        from ClientCookie import response_seek_wrapper
+        from mechanize import response_seek_wrapper
         hdrs = {"Content-type": "text/html"}
         r = TestUnSeekableResponse(self.text, hdrs)
         rsw = response_seek_wrapper(r)
@@ -182,7 +177,33 @@
         rsw2.close()
 
     def testSetResponseData(self):
-        from ClientCookie import response_seek_wrapper
+        from mechanize import response_seek_wrapper
+        r = TestUnSeekableResponse(self.text, {'blah': 'yawn'})
+        rsw = response_seek_wrapper(r)
+        rsw.set_data("""\
+A Seeming somwhat more than View;
+  That doth instruct the Mind
+  In Things that ly behind,
+""")
+        self.assertEqual(rsw.read(9), "A Seeming")
+        self.assertEqual(rsw.read(13), " somwhat more")
+        rsw.seek(0)
+        self.assertEqual(rsw.read(9), "A Seeming")
+        self.assertEqual(rsw.readline(), " somwhat more than View;\n")
+        rsw.seek(0)
+        self.assertEqual(rsw.readline(), "A Seeming somwhat more than View;\n")
+        rsw.seek(-1, 1)
+        self.assertEqual(rsw.read(7), "\n  That")
+
+        r = TestUnSeekableResponse(self.text, {'blah': 'yawn'})
+        rsw = response_seek_wrapper(r)
+        rsw.set_data(self.text)
+        self._test2(rsw)
+        rsw.seek(0)
+        self._test4(rsw)
+
+    def testSetResponseData(self):
+        from mechanize import response_seek_wrapper
         r = TestUnSeekableResponse(self.text, {'blah': 'yawn'})
         rsw = response_seek_wrapper(r)
         rsw.set_data("""\

Modified: wwwsearch/mechanize/trunk/test/test_urllib2.py
==============================================================================
--- wwwsearch/mechanize/trunk/test/test_urllib2.py	(original)
+++ wwwsearch/mechanize/trunk/test/test_urllib2.py	Sat May  6 14:09:50 2006
@@ -12,21 +12,16 @@
 import unittest, StringIO, os, sys, UserDict
 
 import urllib2
-from ClientCookie._urllib2_support import Request, AbstractHTTPHandler, \
+from mechanize._urllib2_support import Request, AbstractHTTPHandler, \
      build_opener, parse_head, urlopen
-from ClientCookie._Util import startswith
-from ClientCookie import HTTPRedirectHandler, HTTPRequestUpgradeProcessor, \
+from mechanize._Util import startswith
+from mechanize import HTTPRedirectHandler, HTTPRequestUpgradeProcessor, \
      HTTPEquivProcessor, HTTPRefreshProcessor, SeekableProcessor, \
      HTTPCookieProcessor, HTTPRefererProcessor, \
      HTTPErrorProcessor, HTTPHandler
-from ClientCookie import OpenerDirector
+from mechanize import OpenerDirector
 
-try: True
-except NameError:
-    True = 1
-    False = 0
-
-## from ClientCookie import getLogger, DEBUG
+## from mechanize import getLogger, DEBUG
 ## l = getLogger("ClientCookie")
 ## l.setLevel(DEBUG)
 
@@ -580,7 +575,7 @@
         except ImportError:
             return  # skip test
         else:
-            from ClientCookie import HTTPRobotRulesProcessor
+            from mechanize import HTTPRobotRulesProcessor
         rfpc = MockRobotFileParserClass()
         h = HTTPRobotRulesProcessor(rfpc)
 
@@ -770,7 +765,7 @@
 class UnescapeTests(unittest.TestCase):
 
     def test_unescape_charref(self):
-        from ClientCookie._urllib2_support import \
+        from mechanize._urllib2_support import \
              unescape_charref, get_entitydefs
         mdash_utf8 = u"\u2014".encode("utf-8")
         for ref, codepoint, utf8, latin1 in [
@@ -783,7 +778,7 @@
             self.assertEqual(unescape_charref(ref, 'utf-8'), utf8)
 
     def test_get_entitydefs(self):
-        from ClientCookie._urllib2_support import get_entitydefs
+        from mechanize._urllib2_support import get_entitydefs
         ed = get_entitydefs()
         for name, codepoint in [
             ("amp", ord(u"&")),
@@ -796,7 +791,7 @@
 
     def test_unescape(self):
         import htmlentitydefs
-        from ClientCookie._urllib2_support import unescape, get_entitydefs
+        from mechanize._urllib2_support import unescape, get_entitydefs
         data = "& < — — —"
         mdash_utf8 = u"\u2014".encode("utf-8")
         ue = unescape(data, get_entitydefs(), "utf-8")
@@ -814,7 +809,7 @@
 
     def test(self):
         # XXX XHTML
-        from ClientCookie import HeadParser
+        from mechanize import HeadParser
         htmls = [
             ("""<meta http-equiv="refresh" content="1; http://example.com/">
             """,
@@ -855,7 +850,7 @@
 
     def test_cookie_redirect(self):
         # cookies shouldn't leak into redirected requests
-        from ClientCookie import CookieJar, build_opener, HTTPHandler, \
+        from mechanize import CookieJar, build_opener, HTTPHandler, \
              HTTPCookieProcessor
         from urllib2 import HTTPError
 
@@ -920,7 +915,7 @@
             self.assert_(False)
 
     def _methnames(self, *objs):
-        from ClientCookie._Opener import methnames
+        from mechanize._Opener import methnames
         r = []
         for i in range(len(objs)):
             obj = objs[i]


More information about the wwwsearch-commits mailing list