|
|
|
@ -15,8 +15,7 @@ import unittest
|
|
|
|
|
from logging import StreamHandler |
|
|
|
|
from flask.testsuite import FlaskTestCase, catch_warnings, catch_stderr |
|
|
|
|
from werkzeug.http import parse_cache_control_header, parse_options_header |
|
|
|
|
import six |
|
|
|
|
from flask._compat import StringIO |
|
|
|
|
from flask._compat import StringIO, text_type |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def has_encoding(name): |
|
|
|
@ -34,7 +33,7 @@ class JSONTestCase(FlaskTestCase):
|
|
|
|
|
app = flask.Flask(__name__) |
|
|
|
|
@app.route('/json', methods=['POST']) |
|
|
|
|
def return_json(): |
|
|
|
|
return six.text_type(flask.request.json) |
|
|
|
|
return text_type(flask.request.json) |
|
|
|
|
c = app.test_client() |
|
|
|
|
rv = c.post('/json', data='malformed', content_type='application/json') |
|
|
|
|
self.assert_equal(rv.status_code, 400) |
|
|
|
@ -43,7 +42,7 @@ class JSONTestCase(FlaskTestCase):
|
|
|
|
|
app = flask.Flask(__name__) |
|
|
|
|
@app.route('/json', methods=['POST']) |
|
|
|
|
def return_json(): |
|
|
|
|
return six.text_type(flask.request.json) |
|
|
|
|
return text_type(flask.request.json) |
|
|
|
|
c = app.test_client() |
|
|
|
|
rv = c.post('/json', data='malformed', content_type='application/json') |
|
|
|
|
self.assert_equal(rv.status_code, 400) |
|
|
|
@ -95,7 +94,7 @@ class JSONTestCase(FlaskTestCase):
|
|
|
|
|
app = flask.Flask(__name__) |
|
|
|
|
@app.route('/add', methods=['POST']) |
|
|
|
|
def add(): |
|
|
|
|
return six.text_type(flask.request.json['a'] + flask.request.json['b']) |
|
|
|
|
return text_type(flask.request.json['a'] + flask.request.json['b']) |
|
|
|
|
c = app.test_client() |
|
|
|
|
rv = c.post('/add', data=flask.json.dumps({'a': 1, 'b': 2}), |
|
|
|
|
content_type='application/json') |
|
|
|
@ -506,7 +505,7 @@ class StreamingTestCase(FlaskTestCase):
|
|
|
|
|
def close(self): |
|
|
|
|
called.append(42) |
|
|
|
|
def next(self): |
|
|
|
|
return six.advance_iterator(self._gen) |
|
|
|
|
return next(self._gen) |
|
|
|
|
@app.route('/') |
|
|
|
|
def index(): |
|
|
|
|
def generate(): |
|
|
|
|