Browse Source

Add test for deprecated flask.Request properties.

pull/1206/head
INADA Naoki 10 years ago
parent
commit
4d4a639ba4
  1. 40
      tests/test_deprecations.py

40
tests/test_deprecations.py

@ -8,3 +8,43 @@
:copyright: (c) 2014 by Armin Ronacher.
:license: BSD, see LICENSE for more details.
"""
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

Loading…
Cancel
Save