Skip to content

Commit fe421a3

Browse files
author
Johannes Gijsbers
committed
Use assertRaises...
...instead of introducing _nocheck machinery into assertRaisesMessage.
1 parent 60ace32 commit fe421a3

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

test/test_actions.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,15 @@ def setUp(self):
3838
self.client.form = self.form
3939

4040
class ShowActionTestCase(ActionTestCase):
41-
_nocheck = "don't compare exception values (the exception is enough)"
4241
def assertRaisesMessage(self, exception, callable, message, *args,
43-
**kwargs):
42+
**kwargs):
43+
"""An extension of assertRaises, which also checks the exception
44+
message. We need this because we rely on exception messages when
45+
redirecting.
46+
"""
4447
try:
4548
callable(*args, **kwargs)
4649
except exception, msg:
47-
if message is self._nocheck:
48-
return
4950
self.assertEqual(str(msg), message)
5051
else:
5152
if hasattr(excClass,'__name__'):
@@ -61,7 +62,7 @@ def testShowAction(self):
6162
self.assertRaises(ValueError, action.handle)
6263

6364
self.form.value.append(MiniFieldStorage('@type', 'issue'))
64-
self.assertRaisesMessage(SeriousError, action.handle, self._nocheck)
65+
self.assertRaises(SeriousError, action.handle)
6566

6667
self.form.value.append(MiniFieldStorage('@number', '1'))
6768
self.assertRaisesMessage(Redirect, action.handle, 'BASE/issue1')

0 commit comments

Comments
 (0)