Michael Merickel
2011-08-12 352d516f90ec3420e637cc237e42c4fab081ad17
Added checks to config.add_tween for over/under ingress/main.
2 files modified
20 ■■■■■ changed files
pyramid/config.py 4 ●●●● patch | view | raw | blame | history
pyramid/tests/test_config.py 16 ●●●●● patch | view | raw | blame | history
pyramid/config.py
@@ -1050,10 +1050,10 @@
        if alias in (MAIN, INGRESS):
            raise ConfigurationError('%s is a reserved tween name' % alias)
        if over is INGRESS:
        if over is INGRESS or hasattr(over, '__iter__') and INGRESS in over:
            raise ConfigurationError('%s cannot be over INGRESS' % name)
        if under is MAIN:
        if under is MAIN or hasattr(under, '__iter__') and MAIN in under:
            raise ConfigurationError('%s cannot be under MAIN' % name)
        registry = self.registry
pyramid/tests/test_config.py
@@ -752,6 +752,14 @@
            config.add_tween, 'pyramid.tests.test_config.dummy_tween_factory',
            over=INGRESS)
    def test_add_tween_over_ingress_iterable(self):
        from pyramid.exceptions import ConfigurationError
        from pyramid.tweens import INGRESS
        config = self._makeOne()
        self.assertRaises(ConfigurationError,
            config.add_tween, 'pyramid.tests.test_config.dummy_tween_factory',
            over=('a', INGRESS))
    def test_add_tween_under_main(self):
        from pyramid.exceptions import ConfigurationError
        from pyramid.tweens import MAIN
@@ -760,6 +768,14 @@
            config.add_tween, 'pyramid.tests.test_config.dummy_tween_factory',
            under=MAIN)
    def test_add_tween_under_main_iterable(self):
        from pyramid.exceptions import ConfigurationError
        from pyramid.tweens import MAIN
        config = self._makeOne()
        self.assertRaises(ConfigurationError,
            config.add_tween, 'pyramid.tests.test_config.dummy_tween_factory',
            under=('a', MAIN))
    def test_add_subscriber_defaults(self):
        from zope.interface import implements
        from zope.interface import Interface