Permalink
Browse files

Tests for fixing issue #621

  • Loading branch information...
wwitzel3 committed Aug 3, 2012
1 parent 92b4566 commit 0d8ff5b39aefaf2a9b3fdd79894d855e59ed9a2e
@@ -43,3 +43,11 @@ def dummy_extend(config, discrim):
def dummy_extend2(config, discrim):
config.action(discrim, None, config.registry)
+from functools import partial
+dummy_partial = partial(dummy_extend, discrim='partial')
+
+class DummyCallable(object):
+ def __call__(self, config, discrim):
+ config.action(discrim, None, config.package)
+dummy_callable = DummyCallable()
+
@@ -1414,6 +1414,32 @@ def test_extend_with_dotted_name(self):
self.assertEqual(action['callable'], None)
self.assertEqual(action['args'], test_config)
+ def test_add_directive_with_partial(self):
+ from pyramid.tests import test_config
+ config = self.config
+ config.add_directive(
+ 'dummy_partial', 'pyramid.tests.test_config.dummy_partial')
+ self.assertTrue(hasattr(config, 'dummy_partial'))
+ config.dummy_partial()
+ after = config.action_state
+ action = after.actions[-1]
+ self.assertEqual(action['discriminator'], 'partial')
+ self.assertEqual(action['callable'], None)
+ self.assertEqual(action['args'], test_config)
+
+ def test_add_directive_with_custom_callable(self):
+ from pyramid.tests import test_config
+ config = self.config
+ config.add_directive(
+ 'dummy_callable', 'pyramid.tests.test_config.dummy_callable')
+ self.assertTrue(hasattr(config, 'dummy_callable'))
+ config.dummy_callable('discrim')
+ after = config.action_state
+ action = after.actions[-1]
+ self.assertEqual(action['discriminator'], 'discrim')
+ self.assertEqual(action['callable'], None)
+ self.assertEqual(action['args'], test_config)
+
def test_extend_with_python_callable(self):
from pyramid.tests import test_config
config = self.config

0 comments on commit 0d8ff5b

Please sign in to comment.