Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* Fix ImportError if sqlite3 not available
 * Fix a couple of functional test not to wait 5 seconds each
  • Loading branch information
jjlee committed Sep 24, 2008
1 parent 1d5485e commit 2e763f2
Show file tree
Hide file tree
Showing 3 changed files with 215 additions and 213 deletions.
7 changes: 4 additions & 3 deletions functional_tests.py
Expand Up @@ -90,6 +90,7 @@ def refresh_request(seconds):
uri = urljoin(self.uri, "/cgi-bin/cookietest.cgi")
val = urllib.quote_plus('%d; url="%s"' % (seconds, self.uri))
return uri + ("?refresh=%s" % val)
self.browser.set_handle_refresh(True, honor_time=False)
r = self.browser.open(refresh_request(5))
self.assertEqual(r.geturl(), self.uri)
# Set a maximum refresh time of 30 seconds (these long refreshes tend
Expand Down Expand Up @@ -287,9 +288,9 @@ class FunctionalTests(TestCase):

def test_referer(self):
br = mechanize.Browser()
br.set_handle_refresh(True, honor_time=False)
referer = urljoin(self.uri, "bits/referertest.html")
info = urljoin(self.uri, "/cgi-bin/cookietest.cgi")

r = br.open(info)
self.assert_(referer not in r.get_data())

Expand Down Expand Up @@ -433,8 +434,8 @@ def test_firefox3_cookiejar(self):
try:
mechanize.Firefox3CookieJar
except AttributeError:
# firefox 3 cookiejar is only supported in Python 2.5 and later
self.assert_(sys.version_info[:2] < (2, 5))
# firefox 3 cookiejar is only supported in Python 2.5 and later;
# also, sqlite3 must be available
return

filename = tempfile.mktemp()
Expand Down
7 changes: 6 additions & 1 deletion mechanize/__init__.py
Expand Up @@ -119,7 +119,12 @@
from _lwpcookiejar import LWPCookieJar, lwp_cookie_str
# 2.4 raises SyntaxError due to generator / try/finally use
if sys.version_info[:2] > (2,4):
from _firefox3cookiejar import Firefox3CookieJar
try:
import sqlite3
except ImportError:
pass
else:
from _firefox3cookiejar import Firefox3CookieJar
from _mozillacookiejar import MozillaCookieJar
from _msiecookiejar import MSIECookieJar

Expand Down

0 comments on commit 2e763f2

Please sign in to comment.