Skip to content

Commit

Permalink
Pass kwargs through URL to superclass
Browse files Browse the repository at this point in the history
Fixes #702
See #701
  • Loading branch information
joshfriend committed Sep 20, 2017
1 parent ce91338 commit efca71f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions flask_restful/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@ class Url(Raw):
:param scheme: URL scheme specifier (e.g. ``http``, ``https``)
:type scheme: str
"""
def __init__(self, endpoint=None, absolute=False, scheme=None):
super(Url, self).__init__()
def __init__(self, endpoint=None, absolute=False, scheme=None, **kwargs):
super(Url, self).__init__(**kwargs)
self.endpoint = endpoint
self.absolute = absolute
self.scheme = scheme
Expand Down
8 changes: 8 additions & 0 deletions tests/test_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,14 @@ def test_url_with_blueprint_absolute_scheme(self):
with app.test_request_context("/foo/hey", base_url="http://localhost"):
self.assertEquals("https://localhost/foo/3", field.output("hey", Foo()))

def test_url_superclass_kwargs(self):
app = Flask(__name__)
app.add_url_rule("/<hey>", "foobar", view_func=lambda x: x)
field = fields.Url(absolute=True, attribute='hey')

with app.test_request_context("/hey"):
self.assertEquals("http://localhost/3", field.output("hey", Foo()))

def test_int(self):
field = fields.Integer()
self.assertEquals(3, field.output("hey", {'hey': 3}))
Expand Down

2 comments on commit efca71f

@Hermlite
Copy link

@Hermlite Hermlite commented on efca71f Nov 23, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flask-RESTful (0.3.6)
Is it not updated in python3.6.3 ?
I use pip install flask-restful, It's the same as before

@joshfriend
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tianruoliang python3.6 is supported by flask-restful, if you have an actual problem, please open an issue

Please sign in to comment.