From f168197609169fb01b65adeb3eb59d069000fe2c Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Mon, 28 Mar 2011 07:14:51 -0400 Subject: [PATCH] branch coverage --- pyramid/config.py | 7 +++++-- pyramid/tests/test_config.py | 6 ++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/pyramid/config.py b/pyramid/config.py index 047a9d2dea..0699c7281c 100644 --- a/pyramid/config.py +++ b/pyramid/config.py @@ -2949,7 +2949,6 @@ def requestonly(view, attr=None): return False args = argspec[0] - defaults = argspec[3] if hasattr(fn, 'im_func'): # it's an instance method @@ -2962,7 +2961,11 @@ def requestonly(view, attr=None): if len(args) == 1: return True - elif args[0] == 'request': + defaults = argspec[3] + if defaults is None: + defaults = () + + if args[0] == 'request': if len(args) - len(defaults) == 1: return True diff --git a/pyramid/tests/test_config.py b/pyramid/tests/test_config.py index ec0a7f7def..16b1f7eff4 100644 --- a/pyramid/tests/test_config.py +++ b/pyramid/tests/test_config.py @@ -4407,6 +4407,12 @@ def __init__(self, request, foo=1, bar=2): """ """ self.assertTrue(self._callFUT(foo)) + def test_newstyle_class_init_firstname_request_with_secondname(self): + class foo(object): + def __init__(self, request, two): + """ """ + self.assertFalse(self._callFUT(foo)) + def test_newstyle_class_init_noargs(self): class foo(object): def __init__():