Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Resolves issue #621 #647

Merged
merged 2 commits into from

2 participants

@wwitzel3

Resolves Pylons/pyramid/#621

@mcdonc mcdonc merged commit 0f0629f into from
@mcdonc
Owner

Thanks Wayne!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 3, 2012
  1. @wwitzel3

    Tests for fixing issue #621

    wwitzel3 authored
  2. @wwitzel3

    Fix for issue #621

    wwitzel3 authored
This page is out of date. Refresh to see the latest.
View
9 pyramid/config/util.py
@@ -1,6 +1,8 @@
import re
import traceback
+from functools import update_wrapper
+
from zope.interface import implementer
from pyramid.interfaces import IActionInfo
@@ -59,9 +61,10 @@ def wrapper(self, *arg, **kw):
finally:
self._ainfo.pop()
return result
- wrapper.__name__ = wrapped.__name__
- wrapper.__doc__ = wrapped.__doc__
- wrapper.__docobj__ = wrapped # for sphinx
+
+ if hasattr(wrapped, '__name__'):
+ update_wrapper(wrapper, wrapped)
+ wrapper.__docobj__ = wrapped
return wrapper
def make_predicates(xhr=None, request_method=None, path_info=None,
View
8 pyramid/tests/test_config/__init__.py
@@ -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()
+
View
26 pyramid/tests/test_config/test_init.py
@@ -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
View
0  pyramid/tests/test_config/test_init.py:TestConfigurator_add_directive
No changes.
Something went wrong with that request. Please try again.