- [bug] Fixed bug in plugin loader to correctly raise exception when non-existent plugin is specified.
diff --git a/CHANGES b/CHANGES index c9e899e..46465f1 100644 --- a/CHANGES +++ b/CHANGES
@@ -11,6 +11,10 @@ identifiers from the context the same way as that of <%block> and <%filter>. +- [bug] Fixed bug in plugin loader to correctly + raise exception when non-existent plugin + is specified. + 0.7.2 - [bug] Fixed regression in 0.7.1 where AST parsing for Py2.4 was broken.
diff --git a/mako/util.py b/mako/util.py index 00c51e4..4b88ae5 100644 --- a/mako/util.py +++ b/mako/util.py
@@ -84,7 +84,7 @@ def load(self, name): if name in self.impls: - return self.impls[name]() + return self.impls[name]() else: import pkg_resources for impl in pkg_resources.iter_entry_points( @@ -93,6 +93,7 @@ self.impls[name] = impl.load return impl.load() else: + from mako import exceptions raise exceptions.RuntimeException( "Can't load plugin %s %s" % (self.group, name))
diff --git a/test/test_util.py b/test/test_util.py index 04b2c09..b875f53 100644 --- a/test/test_util.py +++ b/test/test_util.py
@@ -2,8 +2,8 @@ import os import unittest -from mako import util -from test import eq_, skip_if +from mako import util, exceptions +from test import eq_, skip_if, assert_raises_message class UtilTest(unittest.TestCase): def test_fast_buffer_write(self): @@ -40,3 +40,11 @@ module = util.load_module('mako.template', fn) import mako.template self.assertEqual(module, mako.template) + + def test_load_plugin_failure(self): + loader = util.PluginLoader("fakegroup") + assert_raises_message( + exceptions.RuntimeException, + "Can't load plugin fakegroup fake", + loader.load, "fake" + )