From 922b1d40c4523fdcf9b6f37f9ccd24fda80ec592 Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Tue, 21 May 2013 20:05:34 -0400 Subject: normalize exception messages, coverage --- pyramid/mako_templating.py | 15 ++++++++------- pyramid/tests/test_mako_templating.py | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/pyramid/mako_templating.py b/pyramid/mako_templating.py index 31c398862..8d4583d82 100644 --- a/pyramid/mako_templating.py +++ b/pyramid/mako_templating.py @@ -22,19 +22,20 @@ from pyramid.interfaces import ITemplateRenderer from pyramid.settings import asbool from pyramid.util import DottedNameResolver +def _no_mako(*arg, **kw): # pragma: no cover + raise NotImplementedError( + "'mako' package is not importable (maybe downgrade MarkupSafe to " + "0.16 or below if you're using Python 3.2)" + ) + try: from mako.lookup import TemplateLookup except (ImportError, SyntaxError, AttributeError): #pragma NO COVER - def no_mako(*arg, **kw): - raise NotImplementedError( - "'mako' package is not importable (maybe downgrade MarkupSafe to " - "0.16 or below if you're using Python 3.2)" - ) class TemplateLookup(object): def __init__(self, **kw): for name in ('adjust_uri', 'get_template', 'filename_to_uri', 'put_string', 'put_template'): - setattr(self, name, no_mako) + setattr(self, name, _no_mako) self.filesystem_checks = False try: @@ -47,7 +48,7 @@ try: from mako.exceptions import text_error_template except (ImportError, SyntaxError, AttributeError): #pragma NO COVER def text_error_template(lookup=None): - raise NotImplementedError("'mako' not importable") + _no_mako() class IMakoLookup(Interface): diff --git a/pyramid/tests/test_mako_templating.py b/pyramid/tests/test_mako_templating.py index 75faa771d..f607a5497 100644 --- a/pyramid/tests/test_mako_templating.py +++ b/pyramid/tests/test_mako_templating.py @@ -30,7 +30,7 @@ def maybe_unittest(): # so these tests should not be skipped on those platforms. try: import mako.lookup - except (ImportError, SyntaxError, AttributeError): + except (ImportError, SyntaxError, AttributeError): # pragma: no cover return object else: return unittest.TestCase -- cgit v1.2.3