Skip to content
This repository has been archived by the owner on Oct 18, 2022. It is now read-only.

Commit

Permalink
bugfix: @methodview decorator did not have a @wraps
Browse files Browse the repository at this point in the history
  • Loading branch information
kolypto committed Dec 18, 2019
1 parent ffe0f23 commit 0a534ce
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions flask_jsontools/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

import inspect
from collections import defaultdict
from functools import wraps

from flask.views import View, with_metaclass
from flask import request
from werkzeug.exceptions import MethodNotAllowed
Expand Down Expand Up @@ -31,6 +33,7 @@ def decorator(self, func):
""" Wrapper function to decorate a function """
# This wrapper seems useless, but in fact is serves the purpose
# of being a clean namespace for setting custom attributes
@wraps(func)
def wrapper(*args, **kwargs):
return func(*args, **kwargs)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
setup(
# http://pythonhosted.org/setuptools/setuptools.html
name='flask_jsontools',
version='0.1.6',
version='0.1.7',
author='Mark Vartanyan',
author_email='kolypto@gmail.com',

Expand Down
4 changes: 4 additions & 0 deletions tests/methodview-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ def _testRequest(self, method, path, expected_code, expected_response=None):
if expected_response is not None:
self.assertEqual(rv.get_json(), expected_response)

def test_method_view_wrapped(self):
# Correctly wrapped with @wraps
self.assertEqual(RestView.custom.__name__, 'custom')

def test_method_view(self):
""" Test MethodView(), low-level testing """
self.assertTrue(CrudView.list._methodview.matches('GET', {'a'}))
Expand Down

0 comments on commit 0a534ce

Please sign in to comment.