summaryrefslogtreecommitdiff
path: root/test/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/__init__.py')
-rw-r--r--test/__init__.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/__init__.py b/test/__init__.py
index 3280216..f9e3118 100644
--- a/test/__init__.py
+++ b/test/__init__.py
@@ -1,6 +1,7 @@
from mako.template import Template
import unittest, os
from mako.util import function_named, py3k
+import re
from nose import SkipTest
@@ -67,6 +68,14 @@ def assert_raises(except_cls, callable_, *args, **kw):
# assert outside the block so it works for AssertionError too !
assert success, "Callable did not raise an exception"
+def assert_raises_message(except_cls, msg, callable_, *args, **kwargs):
+ try:
+ callable_(*args, **kwargs)
+ assert False, "Callable did not raise an exception"
+ except except_cls, e:
+ assert re.search(msg, str(e)), "%r !~ %s" % (msg, e)
+ print str(e)
+
def skip_if(predicate, reason=None):
"""Skip a test if predicate is true."""
reason = reason or predicate.__name__