From d0e1bbf3d0faf72bdd93dae1f193c9ec6607a56e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionu=C8=9B=20Ar=C8=9B=C4=83ri=C8=99i?= Date: Mon, 31 Aug 2015 22:58:00 +0100 Subject: [PATCH] add working test case for explicit params We will later make it fail, but want to show a nice diff in the next commit. --- test_classy/test_decorators.py | 4 +++- test_classy/view_classes.py | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/test_classy/test_decorators.py b/test_classy/test_decorators.py index c346c72..1d1dd9e 100644 --- a/test_classy/test_decorators.py +++ b/test_classy/test_decorators.py @@ -56,4 +56,6 @@ def test_params_decorator_delete(): eq_(b"Params Decorator Delete 1234", resp.data) - +def test_explicit_params_decorator(): + resp = client.get('/decorated/explicit/foo/bar') + eq_(b"Explicit param foobar", resp.data) diff --git a/test_classy/view_classes.py b/test_classy/view_classes.py index 5ad1e3a..e9a82d4 100644 --- a/test_classy/view_classes.py +++ b/test_classy/view_classes.py @@ -186,6 +186,13 @@ def decorated_function(*args, **kwargs): return decorator +def explicit_params_decorator(f): + @wraps(f) + def wrapper(*args, **kwargs): + return f(*args, **kwargs) + return wrapper + + def recursive_decorator(f): @wraps(f) def decorated_view(*args, **kwargs): @@ -253,6 +260,9 @@ def someval(self, val): def anotherval(self, val): return "Anotherval " + val + @explicit_params_decorator + def explicit(self, arg1, arg2): + return "Explicit param " + arg1 + arg2 class InheritanceView(BasicView):