def test_simple(self): def f(user, a, request): pass self.assertEqual( inject_args(f, ['a'], user='******', request='request'), ['user', 'a', 'request']) def f(a, request): pass self.assertEqual( inject_args(f, ['a'], user='******', request='request'), ['a', 'request']) def f(user, a): pass self.assertEqual( inject_args(f, ['a'], user='******', request='request'), ['user', 'a'])
def test_simple(self): def f(user, a, request): pass self.assertEqual(inject_args(f, ['a'], user='******', request='request'), ['user', 'a', 'request']) def f(a, request): pass self.assertEqual(inject_args(f, ['a'], user='******', request='request'), ['a', 'request']) def f(user, a): pass self.assertEqual(inject_args(f, ['a'], user='******', request='request'), ['user', 'a'])
def application(environ, start_response): request = Request(environ) try: trace = routes(request) view = trace.target args, kwargs = trace.args, trace.kwargs args = inject_args(view, args, request=request) response = view(*args, **kwargs) if not isinstance(response, Response): response = process_renderer(trace, response) except NoMatchFound, e: response = e.response