| | |
| | | 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) |
| | |
| | | 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 |
| | |
| | | return self |
| | | |
| | | def render_unicode(self, **values): |
| | | if self.exc: |
| | | raise self.exc |
| | | self.values = values |
| | | return u'result' |
| | | |