diff options
| author | Chris McDonough <chrism@plope.com> | 2012-01-22 00:28:47 -0500 |
|---|---|---|
| committer | Chris McDonough <chrism@plope.com> | 2012-01-22 00:28:47 -0500 |
| commit | f8bfc6ceed3b6d059749c4baf2feec71a8211694 (patch) | |
| tree | aec41f6e56c2d82bf8e28424dc7cc1e34da27415 | |
| parent | a3a71196b3f105b48caf0ce0f28e10cc02d9012e (diff) | |
| download | pyramid-f8bfc6ceed3b6d059749c4baf2feec71a8211694.tar.gz pyramid-f8bfc6ceed3b6d059749c4baf2feec71a8211694.tar.bz2 pyramid-f8bfc6ceed3b6d059749c4baf2feec71a8211694.zip | |
- More informative error message when a ``config.include`` cannot find an
``includeme``. See https://github.com/Pylons/pyramid/pull/392.
Closes #392.
| -rw-r--r-- | CHANGES.txt | 6 | ||||
| -rw-r--r-- | pyramid/config/__init__.py | 8 | ||||
| -rw-r--r-- | pyramid/tests/test_config/test_init.py | 5 |
3 files changed, 18 insertions, 1 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 81f420a84..2a8515d01 100644 --- a/CHANGES.txt +++ b/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 --------- diff --git a/pyramid/config/__init__.py b/pyramid/config/__init__.py index 04f9b6fb5..57ab7e13a 100644 --- a/pyramid/config/__init__.py +++ b/pyramid/config/__init__.py @@ -704,7 +704,13 @@ class Configurator( 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) diff --git a/pyramid/tests/test_config/test_init.py b/pyramid/tests/test_config/test_init.py index 3aa2c7810..a866bed55 100644 --- a/pyramid/tests/test_config/test_init.py +++ b/pyramid/tests/test_config/test_init.py @@ -712,6 +712,11 @@ pyramid.tests.test_config.dummy_include2""", 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): |
