Skip to content
This repository

Resolves issue #621 #647

Merged
merged 2 commits into from over 1 year ago

2 participants

Wayne Witzel III Chris McDonough
Wayne Witzel III

Resolves Pylons/pyramid/#621

Chris McDonough mcdonc merged commit 0f0629f into from August 24, 2012
Chris McDonough mcdonc closed this August 24, 2012
Chris McDonough
Owner

Thanks Wayne!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 2 unique commits by 1 author.

Aug 03, 2012
Wayne Witzel III Tests for fixing issue #621 0d8ff5b
Wayne Witzel III Fix for issue #621 0f0629f
This page is out of date. Refresh to see the latest.
9  pyramid/config/util.py
... ...
@@ -1,6 +1,8 @@
1 1
 import re
2 2
 import traceback
3 3
 
  4
+from functools import update_wrapper
  5
+
4 6
 from zope.interface import implementer
5 7
 
6 8
 from pyramid.interfaces import IActionInfo
@@ -59,9 +61,10 @@ def wrapper(self, *arg, **kw):
59 61
         finally:
60 62
             self._ainfo.pop()
61 63
         return result
62  
-    wrapper.__name__ = wrapped.__name__
63  
-    wrapper.__doc__ = wrapped.__doc__
64  
-    wrapper.__docobj__ = wrapped # for sphinx
  64
+
  65
+    if hasattr(wrapped, '__name__'):
  66
+        update_wrapper(wrapper, wrapped)
  67
+    wrapper.__docobj__ = wrapped
65 68
     return wrapper
66 69
 
67 70
 def make_predicates(xhr=None, request_method=None, path_info=None,
8  pyramid/tests/test_config/__init__.py
@@ -43,3 +43,11 @@ def dummy_extend(config, discrim):
43 43
 def dummy_extend2(config, discrim):
44 44
     config.action(discrim, None, config.registry)
45 45
 
  46
+from functools import partial
  47
+dummy_partial = partial(dummy_extend, discrim='partial')
  48
+
  49
+class DummyCallable(object):
  50
+    def __call__(self, config, discrim):
  51
+        config.action(discrim, None, config.package)
  52
+dummy_callable = DummyCallable()
  53
+
26  pyramid/tests/test_config/test_init.py
@@ -1414,6 +1414,32 @@ def test_extend_with_dotted_name(self):
1414 1414
         self.assertEqual(action['callable'], None)
1415 1415
         self.assertEqual(action['args'], test_config)
1416 1416
 
  1417
+    def test_add_directive_with_partial(self):
  1418
+        from pyramid.tests import test_config
  1419
+        config = self.config
  1420
+        config.add_directive(
  1421
+                'dummy_partial', 'pyramid.tests.test_config.dummy_partial')
  1422
+        self.assertTrue(hasattr(config, 'dummy_partial'))
  1423
+        config.dummy_partial()
  1424
+        after = config.action_state
  1425
+        action = after.actions[-1]
  1426
+        self.assertEqual(action['discriminator'], 'partial')
  1427
+        self.assertEqual(action['callable'], None)
  1428
+        self.assertEqual(action['args'], test_config)
  1429
+
  1430
+    def test_add_directive_with_custom_callable(self):
  1431
+        from pyramid.tests import test_config
  1432
+        config = self.config
  1433
+        config.add_directive(
  1434
+                'dummy_callable', 'pyramid.tests.test_config.dummy_callable')
  1435
+        self.assertTrue(hasattr(config, 'dummy_callable'))
  1436
+        config.dummy_callable('discrim')
  1437
+        after = config.action_state
  1438
+        action = after.actions[-1]
  1439
+        self.assertEqual(action['discriminator'], 'discrim')
  1440
+        self.assertEqual(action['callable'], None)
  1441
+        self.assertEqual(action['args'], test_config)
  1442
+
1417 1443
     def test_extend_with_python_callable(self):
1418 1444
         from pyramid.tests import test_config
1419 1445
         config = self.config
0  pyramid/tests/test_config/test_init.py:TestConfigurator_add_directive
No changes.
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.