summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris McDonough <chrism@plope.com>2013-05-21 20:05:34 -0400
committerChris McDonough <chrism@plope.com>2013-05-21 20:05:34 -0400
commit922b1d40c4523fdcf9b6f37f9ccd24fda80ec592 (patch)
tree476a029edff6a909df0f476e52fc3f26c7793dae
parent6b559994fe4006e8cc0d2135f1f4548a60ab8ff0 (diff)
downloadpyramid-922b1d40c4523fdcf9b6f37f9ccd24fda80ec592.tar.gz
pyramid-922b1d40c4523fdcf9b6f37f9ccd24fda80ec592.tar.bz2
pyramid-922b1d40c4523fdcf9b6f37f9ccd24fda80ec592.zip
normalize exception messages, coverage
-rw-r--r--pyramid/mako_templating.py15
-rw-r--r--pyramid/tests/test_mako_templating.py2
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