2011-08-26 11:21:26 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
"""
|
2014-08-31 21:54:45 +02:00
|
|
|
tests.deprecations
|
2014-09-04 16:28:50 +02:00
|
|
|
~~~~~~~~~~~~~~~~~~
|
2011-08-26 11:21:26 +01:00
|
|
|
|
2014-09-03 20:56:10 +02:00
|
|
|
Tests deprecation support. Not used currently.
|
2011-08-26 11:21:26 +01:00
|
|
|
|
2015-01-02 11:35:00 +09:00
|
|
|
:copyright: (c) 2015 by Armin Ronacher.
|
2011-08-26 11:21:26 +01:00
|
|
|
:license: BSD, see LICENSE for more details.
|
|
|
|
|
"""
|
2014-10-15 03:32:04 +09:00
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
import flask
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestRequestDeprecation(object):
|
|
|
|
|
|
|
|
|
|
def test_request_json(self, catch_deprecation_warnings):
|
|
|
|
|
"""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'
|
|
|
|
|
|
|
|
|
|
with catch_deprecation_warnings() as captured:
|
|
|
|
|
c = app.test_client()
|
|
|
|
|
c.post('/', data='{"spam": 42}', content_type='application/json')
|
|
|
|
|
|
|
|
|
|
assert len(captured) == 1
|
|
|
|
|
|
|
|
|
|
def test_request_module(self, catch_deprecation_warnings):
|
|
|
|
|
"""Request.module is deprecated"""
|
|
|
|
|
app = flask.Flask(__name__)
|
|
|
|
|
app.testing = True
|
|
|
|
|
|
|
|
|
|
@app.route('/')
|
|
|
|
|
def index():
|
|
|
|
|
assert flask.request.module is None
|
|
|
|
|
return 'OK'
|
|
|
|
|
|
|
|
|
|
with catch_deprecation_warnings() as captured:
|
|
|
|
|
c = app.test_client()
|
|
|
|
|
c.get('/')
|
|
|
|
|
|
|
|
|
|
assert len(captured) == 1
|