Skip to content
Myr

Use `content_type` kwarg instead of manipulating headers

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Adam Byrtek · committed by Markus Unterwaditzer · parent c4139e0 · Browse files · 2 files+4 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+4 added−5 removed

  • tests:+1 added−0 removed
  • other:+3 added−5 removed

2 files+4 added−5 removed

modified:flask/testing.py+3 added-5 removed
33 unmodified lines
34 path = url.path35 if url.query:36 path += '?' + url.query3738 if json:38 if json is not None:39 if 'data' in kwargs:40 raise RuntimeError('Client cannot provide both `json` and `data`')41 kwargs['data'] = json_dumps(json)4243 # Only set Content-Type when not explicitly provided44 if 'Content-Type' not in kwargs.get('headers', {}):45 new_headers = kwargs.get('headers', {}).copy()46 new_headers['Content-Type'] = 'application/json'47 kwargs['headers'] = new_headers44 if 'content_type' not in kwargs:45 kwargs['content_type'] = 'application/json'4647 return EnvironBuilder(path, base_url, *args, **kwargs)4849
91 unmodified lines
modified:tests/test_testing.py+1 added
213 unmodified lines
214 with app.test_client() as c:215 json_data = {'drink': {'gin': 1, 'tonic': True}, 'price': 10}216 rv = c.post('/api', json=json_data)217 assert rv.status_code == 200218 assert flask.request.is_json219 assert flask.request.get_json() == json_data220221def test_subdomain():222 app = flask.Flask(__name__)
29 unmodified lines