From: richard Date: Sun, 29 Feb 2004 00:41:51 +0000 (+0000) Subject: test fix X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f0c0af8e781b4f6a1d9fdf04d6640584d82e1400;p=roundup.git test fix git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@2129 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/test/test_actions.py b/test/test_actions.py index ebf39df..65a86f4 100755 --- a/test/test_actions.py +++ b/test/test_actions.py @@ -6,7 +6,7 @@ from cgi import FieldStorage, MiniFieldStorage from roundup import hyperdb from roundup.date import Date, Interval from roundup.cgi.actions import * -from roundup.cgi.exceptions import Redirect, Unauthorised +from roundup.cgi.exceptions import Redirect, Unauthorised, SeriousError class MockNull: def __init__(self, **kwargs): @@ -38,14 +38,20 @@ class ActionTestCase(unittest.TestCase): self.client.form = self.form class ShowActionTestCase(ActionTestCase): - def assertRaisesMessage(self, exception, callable, message, *args, **kwargs): + _nocheck = "don't compare exception values (the exception is enough)" + def assertRaisesMessage(self, exception, callable, message, *args, + **kwargs): try: callable(*args, **kwargs) except exception, msg: + if message is self._nocheck: + return self.assertEqual(str(msg), message) else: - if hasattr(excClass,'__name__'): excName = excClass.__name__ - else: excName = str(excClass) + if hasattr(excClass,'__name__'): + excName = excClass.__name__ + else: + excName = str(excClass) raise self.failureException, excName def testShowAction(self): @@ -55,11 +61,18 @@ class ShowActionTestCase(ActionTestCase): self.assertRaises(ValueError, action.handle) self.form.value.append(MiniFieldStorage('@type', 'issue')) - self.assertRaisesMessage(Redirect, action.handle, 'BASE/issue') + self.assertRaisesMessage(SeriousError, action.handle, self._nocheck) self.form.value.append(MiniFieldStorage('@number', '1')) self.assertRaisesMessage(Redirect, action.handle, 'BASE/issue1') + def testShowActionNoType(self): + action = ShowAction(self.client) + self.assertRaises(ValueError, action.handle) + self.form.value.append(MiniFieldStorage('@number', '1')) + self.assertRaisesMessage(ValueError, action.handle, + 'No type specified') + class RetireActionTestCase(ActionTestCase): def testRetireAction(self): self.client.db.security.hasPermission = true