-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add json argument to test.Client.post() #848
Comments
I heavily agree with this idea. I was actually skimming issues to see if theres any talk about a json attribute or method planned for the |
Related: pallets/flask#1416 |
To expand on the spec above, currently I do response = app.post(
'/snippets',
data=json.dumps({'text': 'example'}),
content_type='application/json',
) whereas I would like to do response = app.post(
'/snippets',
json={'text': 'example'},
) |
Looks like #950 was on the way to getting this done, just needs someone with capacity to finish it! |
( last comment I promise !!! ) Looks like this is in already! http://flask.pocoo.org/docs/1.0/testing/#testing-json-apis ✨ |
Hi there. I wondered if it would be useful to have an argument
json
for the methodtest.Client.post()
. The idea would be that you can pass in a request body in the form of a data structure which gets serialized to JSON.You would not be able to set both
data
andjson
, it would simply be a convenience rather than serialize to JSON and then pass in asdata
.This argument is present in
requests.post()
and one reason it might be nice to have it is that makes it possible to keep testing with the Werkzeug client and live testing/monitoring against a production server using Requests closer together.I am happy to submit a PR for this, but I wanted to check first in case it is seen as bloaty or not a good idea for some other reason. Thanks!
The text was updated successfully, but these errors were encountered: