Merge branch 'six' of github.com:ThomasWaldmann/flask into ThomasWaldmann-six
Conflicts: flask/testsuite/__init__.py
This commit is contained in:
commit
8494574fdf
13 changed files with 42 additions and 19 deletions
|
|
@ -10,6 +10,7 @@
|
|||
:license: BSD, see LICENSE for more details.
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
from __future__ import with_statement
|
||||
|
||||
import os
|
||||
|
|
@ -221,4 +222,4 @@ def main():
|
|||
try:
|
||||
unittest.main(testLoader=BetterLoader(), defaultTest='suite')
|
||||
except Exception as e:
|
||||
print 'Error: %s' % e
|
||||
print('Error: %s' % e)
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ from flask.testsuite import FlaskTestCase, emits_module_deprecation_warning
|
|||
from werkzeug.exceptions import BadRequest, NotFound
|
||||
from werkzeug.http import parse_date
|
||||
from werkzeug.routing import BuildError
|
||||
import six
|
||||
|
||||
|
||||
class BasicFunctionalityTestCase(FlaskTestCase):
|
||||
|
|
@ -277,7 +278,7 @@ class BasicFunctionalityTestCase(FlaskTestCase):
|
|||
|
||||
@app.route('/test')
|
||||
def test():
|
||||
return unicode(flask.session.permanent)
|
||||
return six.text_type(flask.session.permanent)
|
||||
|
||||
client = app.test_client()
|
||||
rv = client.get('/')
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ from flask.testsuite import FlaskTestCase, emits_module_deprecation_warning
|
|||
from werkzeug.exceptions import NotFound
|
||||
from werkzeug.http import parse_cache_control_header
|
||||
from jinja2 import TemplateNotFound
|
||||
import six
|
||||
|
||||
|
||||
# import moduleapp here because it uses deprecated features and we don't
|
||||
|
|
@ -304,7 +305,7 @@ class BlueprintTestCase(FlaskTestCase):
|
|||
|
||||
@bp.route('/bar')
|
||||
def bar(bar):
|
||||
return unicode(bar)
|
||||
return six.text_type(bar)
|
||||
|
||||
app = flask.Flask(__name__)
|
||||
app.register_blueprint(bp, url_prefix='/1', url_defaults={'bar': 23})
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ class LimitedLoaderMockWrapper(object):
|
|||
def __getattr__(self, name):
|
||||
if name in ('archive', 'get_filename'):
|
||||
msg = 'Mocking a loader which does not have `%s.`' % name
|
||||
raise AttributeError, msg
|
||||
raise AttributeError(msg)
|
||||
return getattr(self.loader, name)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ from __future__ import with_statement
|
|||
import sys
|
||||
import unittest
|
||||
from flask.testsuite import FlaskTestCase
|
||||
|
||||
from six import reload_module
|
||||
|
||||
class ExtImportHookTestCase(FlaskTestCase):
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ class ExtImportHookTestCase(FlaskTestCase):
|
|||
entry == 'flaskext') and value is not None:
|
||||
sys.modules.pop(entry, None)
|
||||
from flask import ext
|
||||
reload(ext)
|
||||
reload_module(ext)
|
||||
|
||||
# reloading must not add more hooks
|
||||
import_hooks = 0
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ from logging import StreamHandler
|
|||
from StringIO import StringIO
|
||||
from flask.testsuite import FlaskTestCase, catch_warnings, catch_stderr
|
||||
from werkzeug.http import parse_cache_control_header, parse_options_header
|
||||
import six
|
||||
|
||||
|
||||
def has_encoding(name):
|
||||
|
|
@ -35,7 +36,7 @@ class JSONTestCase(FlaskTestCase):
|
|||
app = flask.Flask(__name__)
|
||||
@app.route('/json', methods=['POST'])
|
||||
def return_json():
|
||||
return unicode(flask.request.json)
|
||||
return six.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)
|
||||
|
|
@ -44,7 +45,7 @@ class JSONTestCase(FlaskTestCase):
|
|||
app = flask.Flask(__name__)
|
||||
@app.route('/json', methods=['POST'])
|
||||
def return_json():
|
||||
return unicode(flask.request.json)
|
||||
return six.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)
|
||||
|
|
@ -96,7 +97,7 @@ class JSONTestCase(FlaskTestCase):
|
|||
app = flask.Flask(__name__)
|
||||
@app.route('/add', methods=['POST'])
|
||||
def add():
|
||||
return unicode(flask.request.json['a'] + flask.request.json['b'])
|
||||
return six.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')
|
||||
|
|
@ -507,7 +508,7 @@ class StreamingTestCase(FlaskTestCase):
|
|||
def close(self):
|
||||
called.append(42)
|
||||
def next(self):
|
||||
return self._gen.next()
|
||||
return six.advance_iterator(self._gen)
|
||||
@app.route('/')
|
||||
def index():
|
||||
def generate():
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ from __future__ import with_statement
|
|||
import flask
|
||||
import unittest
|
||||
from flask.testsuite import FlaskTestCase
|
||||
import six
|
||||
|
||||
|
||||
class TestToolsTestCase(FlaskTestCase):
|
||||
|
|
@ -85,7 +86,7 @@ class TestToolsTestCase(FlaskTestCase):
|
|||
|
||||
@app.route('/')
|
||||
def index():
|
||||
return unicode(flask.session['foo'])
|
||||
return six.text_type(flask.session['foo'])
|
||||
|
||||
with app.test_client() as c:
|
||||
with c.session_transaction() as sess:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue