Skip to content

Commit 8b4a9cc

Browse files
committed
More decorator tests and we no longer let things through the argspec loop that aren't functions or methods
1 parent 4eb607b commit 8b4a9cc

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

flask_classy.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,9 @@ def get_true_argspec(method):
308308
inner_method = cell.cell_contents
309309
if inner_method is method:
310310
continue
311+
if not inspect.isfunction(inner_method) \
312+
and not inspect.ismethod(inner_method):
313+
continue
311314
true_argspec = get_true_argspec(inner_method)
312315
if true_argspec:
313316
return true_argspec

test_classy/test_decorators.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,12 @@ def test_recursive_with_route_with_parameter():
4848

4949

5050
def test_params_decorator():
51-
resp = client.get('/decorated/params_decorator/')
51+
resp = client.get('/decorated/params_decorator_method/')
5252
eq_(b"Params Decorator", resp.data)
5353

54+
def test_params_decorator_delete():
55+
resp = client.delete('/decorated/1234')
56+
eq_(b"Params Decorator Delete 1234", resp.data)
57+
5458

5559

test_classy/view_classes.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
from flask_classy import FlaskView, route
22
from functools import wraps
33

4+
VALUE1 = "value1"
5+
6+
def get_value():
7+
return VALUE1
8+
49
class BasicView(FlaskView):
510

611
def index(self):
@@ -215,9 +220,14 @@ def post(self):
215220
return "Post"
216221

217222
@params_decorator("oneval", "anotherval")
218-
def params_decorator(self):
223+
def params_decorator_method(self):
219224
return "Params Decorator"
220225

226+
@params_decorator(get_value(), "value")
227+
def delete(self, obj_id):
228+
return "Params Decorator Delete " + obj_id
229+
230+
221231
@more_recursive(None)
222232
def get_some(self):
223233
return "Get Some"

0 commit comments

Comments
 (0)