[Checkins]
SVN: zc.authorizedotnet/trunk/src/zc/authorizedotnet/tests.py
make the tests work for newer versions of Mechanize (while
maintaining backward
Benji York
benji at zope.com
Tue Jun 27 17:54:02 EDT 2006
Log message for revision 68871:
make the tests work for newer versions of Mechanize (while maintaining backward
compatability)
Changed:
U zc.authorizedotnet/trunk/src/zc/authorizedotnet/tests.py
-=-
Modified: zc.authorizedotnet/trunk/src/zc/authorizedotnet/tests.py
===================================================================
--- zc.authorizedotnet/trunk/src/zc/authorizedotnet/tests.py 2006-06-27 21:39:42 UTC (rev 68870)
+++ zc.authorizedotnet/trunk/src/zc/authorizedotnet/tests.py 2006-06-27 21:54:01 UTC (rev 68871)
@@ -37,14 +37,32 @@
return ClientForm.FormParser.do_input(self, attrs)
-class ScrapedMerchantUiServer(object):
- initialized = False
+def makeMechBrowser():
+ """Create a mechanize browser
- def __init__(self, server, login, password):
+ This tries to paper over two different mechanize APIs, the newest is
+ listed first.
+ """
+ if hasattr(mechanize, 'DefaultFactory'):
+ class MyFactory(mechanize.DefaultFactory):
+ def __init__(self):
+ mechanize.DefaultFactory.__init__(self)
+ self._forms_factory=mechanize.FormsFactory(
+ form_parser_class=TolerantFormParser)
+
+ mech_browser = mechanize.Browser(factory=MyFactory())
+ else:
mech_browser = mechanize.Browser(
forms_factory=mechanize.FormsFactory(
form_parser_class=TolerantFormParser))
+ return mech_browser
+
+class ScrapedMerchantUiServer(object):
+ initialized = False
+
+ def __init__(self, server, login, password):
+ mech_browser = makeMechBrowser()
login_page = 'https://%s/ui/themes/anet/merch.app' % server
self.browser = Browser(mech_browser=mech_browser)
self.browser.open(login_page)
More information about the Checkins
mailing list