summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2011-08-19 01:34:45 -0400
committerChris McDonough <chrism@plope.com>2011-08-19 01:34:45 -0400
commit9f7f4f5219335e8bca108018c699ffdda8f40425 (patch)
treee62a1dd41558f775764b79b66957a4ad0606efa3
parent66da9b2f683ace2c0fa3ce24a607d4239c760434 (diff)
downloadpyramid-9f7f4f5219335e8bca108018c699ffdda8f40425.tar.gz
pyramid-9f7f4f5219335e8bca108018c699ffdda8f40425.tar.bz2
pyramid-9f7f4f5219335e8bca108018c699ffdda8f40425.zip
- Better Mako rendering exceptions via
``pyramid.mako_templating.MakoRenderingException``
-rw-r--r--CHANGES.txt3
-rw-r--r--pyramid/tests/test_mako_templating.py26
2 files changed, 29 insertions, 0 deletions
diff --git a/CHANGES.txt b/CHANGES.txt
index fb45ede81..afcacd90b 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -72,6 +72,9 @@ Features
``authorization_policy``) to override the same settings obtained via an
"include".
+- Better Mako rendering exceptions via
+ ``pyramid.mako_templating.MakoRenderingException``
+
Internal
--------
diff --git a/pyramid/tests/test_mako_templating.py b/pyramid/tests/test_mako_templating.py
index c63895216..49808ed8a 100644
--- a/pyramid/tests/test_mako_templating.py
+++ b/pyramid/tests/test_mako_templating.py
@@ -300,6 +300,17 @@ class MakoLookupTemplateRendererTests(Base, unittest.TestCase):
instance = self._makeOne('path', lookup)
self.assertRaises(ValueError, instance, None, {})
+ def test_call_render_raises(self):
+ from pyramid.mako_templating import MakoRenderingException
+ lookup = DummyLookup(exc=NotImplementedError)
+ instance = self._makeOne('path', lookup)
+ try:
+ instance({}, {})
+ except MakoRenderingException, e:
+ self.assertTrue('NotImplementedError' in e.text)
+ else: # pragma: no cover
+ raise AssertionError
+
def test_implementation(self):
lookup = DummyLookup()
instance = self._makeOne('path', lookup)
@@ -412,7 +423,20 @@ class TestPkgResourceTemplateLookup(unittest.TestCase):
self.assertRaises(TopLevelLookupException, inst.get_template,
'pyramid.tests:fixtures/notthere.mak')
+class TestMakoRenderingException(unittest.TestCase):
+ def _makeOne(self, text):
+ from pyramid.mako_templating import MakoRenderingException
+ return MakoRenderingException(text)
+
+ def test_repr_and_str(self):
+ exc = self._makeOne('text')
+ self.assertEqual(str(exc), 'text')
+ self.assertEqual(repr(exc), 'text')
+
class DummyLookup(object):
+ def __init__(self, exc=None):
+ self.exc = exc
+
def get_template(self, path):
self.path = path
return self
@@ -422,6 +446,8 @@ class DummyLookup(object):
return self
def render_unicode(self, **values):
+ if self.exc:
+ raise self.exc
self.values = values
return u'result'