[Zope-CVS] CVS: Products/CookieCrumbler/tests -
testCookieCrumbler.py:1.6
Shane Hathaway
shane at zope.com
Thu Jan 22 11:41:03 EST 2004
Update of /cvs-repository/Products/CookieCrumbler/tests
In directory cvs.zope.org:/tmp/cvs-serv32520/tests
Modified Files:
testCookieCrumbler.py
Log Message:
Made compatible with Zope 2.7 by raising Redirect instances.
=== Products/CookieCrumbler/tests/testCookieCrumbler.py 1.5 => 1.6 ===
--- Products/CookieCrumbler/tests/testCookieCrumbler.py:1.5 Tue Jul 1 12:42:26 2003
+++ Products/CookieCrumbler/tests/testCookieCrumbler.py Thu Jan 22 11:41:01 2004
@@ -31,7 +31,8 @@
from ZPublisher.HTTPResponse import HTTPResponse
from ZPublisher.BaseRequest import RequestContainer
-from Products.CookieCrumbler.CookieCrumbler import CookieCrumbler, manage_addCC
+from Products.CookieCrumbler.CookieCrumbler \
+ import CookieCrumbler, manage_addCC, Redirect
def makerequest(root, stdout, stdin=None):
@@ -147,7 +148,7 @@
def testAutoLoginRedirection(self):
# Redirect unauthorized anonymous users to the login page
- self.assertRaises('Redirect', self.req.traverse, '/protected')
+ self.assertRaises(Redirect, self.req.traverse, '/protected')
def testDisabledAutoLoginRedirection(self):
@@ -170,8 +171,10 @@
self.req.cookies['__ac_password'] = 'pass-w'
try:
self.req.traverse('/protected')
- except 'Redirect', s:
+ except Redirect, s:
# Test passed
+ if hasattr(s, 'args'):
+ s = s.args[0]
self.assert_(s.find('came_from=') >= 0)
self.assert_(s.find('retry=1') >= 0)
self.assert_(s.find('disable_cookie_login__=1') >= 0)
@@ -185,7 +188,9 @@
self.req['QUERY_STRING'] = 'a:int=1&x:string=y'
try:
self.req.traverse('/protected')
- except 'Redirect', s:
+ except Redirect, s:
+ if hasattr(s, 'args'):
+ s = s.args[0]
to_find = urllib.quote('/protected?' + self.req['QUERY_STRING'])
self.assert_(s.find(to_find) >= 0, s)
else:
@@ -276,7 +281,7 @@
# handler page if that's what the sysadmin really wants.
self.root.cookie_authentication.unauth_page = 'login_form'
self.req.cookies['__ac'] = self.credentials
- self.assertRaises('Redirect', self.req.traverse, '/protected')
+ self.assertRaises(Redirect, self.req.traverse, '/protected')
def testLoginRatherThanResume(self):
@@ -303,8 +308,8 @@
'index_html', 'logged_in', 'logged_out', 'login_form',
'standard_login_footer', 'standard_login_header'))
+def test_suite():
+ return unittest.makeSuite(CookieCrumblerTests)
if __name__ == '__main__':
- unittest.main()
-
-
+ unittest.main(defaultTest='test_suite')
More information about the Zope-CVS
mailing list