2011-08-26 18:21:26 +08:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
2014-09-01 03:54:45 +08:00
|
|
|
tests.deprecations
|
2014-09-04 22:28:50 +08:00
|
|
|
~~~~~~~~~~~~~~~~~~
|
2011-08-26 18:21:26 +08:00
|
|
|
|
2014-09-04 02:56:10 +08:00
|
|
|
Tests deprecation support. Not used currently.
|
2011-08-26 18:21:26 +08:00
|
|
|
|
2015-01-02 10:35:00 +08:00
|
|
|
:copyright: (c) 2015 by Armin Ronacher.
|
2011-08-26 18:21:26 +08:00
|
|
|
:license: BSD, see LICENSE for more details.
|
|
|
|
"""
|
2014-10-15 02:32:04 +08:00
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
import flask
|
|
|
|
|
|
|
|
|
|
|
|
class TestRequestDeprecation(object):
|
|
|
|
|
2016-06-03 19:56:42 +08:00
|
|
|
def test_request_json(self, recwarn):
|
2014-10-15 02:32:04 +08:00
|
|
|
"""Request.json is deprecated"""
|
|
|
|
app = flask.Flask(__name__)
|
|
|
|
app.testing = True
|
|
|
|
|
|
|
|
@app.route('/', methods=['POST'])
|
|
|
|
def index():
|
|
|
|
assert flask.request.json == {'spam': 42}
|
|
|
|
print(flask.request.json)
|
|
|
|
return 'OK'
|
|
|
|
|
2016-06-03 19:56:42 +08:00
|
|
|
c = app.test_client()
|
|
|
|
c.post('/', data='{"spam": 42}', content_type='application/json')
|
|
|
|
recwarn.pop(DeprecationWarning)
|
2014-10-15 02:32:04 +08:00
|
|
|
|
2016-06-03 19:56:42 +08:00
|
|
|
def test_request_module(self, recwarn):
|
2014-10-15 02:32:04 +08:00
|
|
|
"""Request.module is deprecated"""
|
|
|
|
app = flask.Flask(__name__)
|
|
|
|
app.testing = True
|
|
|
|
|
|
|
|
@app.route('/')
|
|
|
|
def index():
|
|
|
|
assert flask.request.module is None
|
|
|
|
return 'OK'
|
|
|
|
|
2016-06-03 19:56:42 +08:00
|
|
|
c = app.test_client()
|
|
|
|
c.get('/')
|
|
|
|
recwarn.pop(DeprecationWarning)
|