Skip to content

Commit

Permalink
- More informative error message when a config.include cannot fin…
Browse files Browse the repository at this point in the history
…d an

  ``includeme``.  See #392.

Closes #392.
  • Loading branch information
mcdonc committed Jan 22, 2012
1 parent a3a7119 commit f8bfc6c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGES.txt
@@ -1,6 +1,12 @@
Next release
============

Features
--------

- More informative error message when a ``config.include`` cannot find an
``includeme``. See https://github.com/Pylons/pyramid/pull/392.

Bug Fixes
---------

Expand Down
8 changes: 7 additions & 1 deletion pyramid/config/__init__.py
Expand Up @@ -704,7 +704,13 @@ def main(global_config, **settings):
c = self.maybe_dotted(callable)
module = inspect.getmodule(c)
if module is c:
c = getattr(module, 'includeme')
try:
c = getattr(module, 'includeme')
except AttributeError:
raise ConfigurationError(
"module %r has no attribute 'includeme'" % (module.__name__)
)

spec = module.__name__ + ':' + c.__name__
sourcefile = inspect.getsourcefile(c)

Expand Down
5 changes: 5 additions & 0 deletions pyramid/tests/test_config/test_init.py
Expand Up @@ -712,6 +712,11 @@ def test_include_with_module_defaults_to_includeme(self):
self.assertEqual(action['callable'], None)
self.assertEqual(action['args'], test_config)

def test_include_with_module_defaults_to_includeme_missing(self):
from pyramid.exceptions import ConfigurationError
config = self._makeOne()
self.assertRaises(ConfigurationError, config.include, 'pyramid.tests')

def test_include_with_route_prefix(self):
root_config = self._makeOne(autocommit=True)
def dummy_subapp(config):
Expand Down

0 comments on commit f8bfc6c

Please sign in to comment.