Merge https://github.com/nmclean/pyramid into nmclean-master
| | |
| | | def requestonly(view, attr=None): |
| | | if attr is None: |
| | | attr = '__call__' |
| | | if inspect.isfunction(view): |
| | | if inspect.isroutine(view): |
| | | fn = view |
| | | elif inspect.isclass(view): |
| | | try: |
| | |
| | | |
| | | args = argspec[0] |
| | | |
| | | if hasattr(fn, 'im_func'): |
| | | # it's an instance method |
| | | if inspect.ismethod(fn): |
| | | if not args: |
| | | return False |
| | | args = args[1:] |
| | |
| | | class Foo: pass |
| | | foo = Foo() |
| | | self.assertFalse(self._callFUT(foo)) |
| | | |
| | | def test_method_onearg_named_request(self): |
| | | class Foo: |
| | | def method(self, request): |
| | | """ """ |
| | | foo = Foo() |
| | | self.assertTrue(self._callFUT(foo.method)) |
| | | |
| | | class Test_isexception(unittest.TestCase): |
| | | def _callFUT(self, ob): |