forked from orbit-oss/flask
don't push app context for test client json
This commit is contained in:
parent
f2c854060a
commit
a4f0f19796
4 changed files with 95 additions and 39 deletions
|
|
@ -73,14 +73,10 @@ def make_test_environ_builder(
|
|||
sep = b'?' if isinstance(url.query, bytes) else '?'
|
||||
path += sep + url.query
|
||||
|
||||
# TODO use EnvironBuilder.json_dumps once we require Werkzeug 0.15
|
||||
if 'json' in kwargs:
|
||||
assert 'data' not in kwargs, (
|
||||
"Client cannot provide both 'json' and 'data'."
|
||||
)
|
||||
|
||||
# push a context so flask.json can use app's json attributes
|
||||
with app.app_context():
|
||||
kwargs['data'] = json_dumps(kwargs.pop('json'))
|
||||
assert 'data' not in kwargs, "Client cannot provide both 'json' and 'data'."
|
||||
kwargs['data'] = json_dumps(kwargs.pop('json'), app=app)
|
||||
|
||||
if 'content_type' not in kwargs:
|
||||
kwargs['content_type'] = 'application/json'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue