Browse Source

Fix some literals

pull/737/head
Markus Unterwaditzer 12 years ago
parent
commit
05f66ad735
  1. 111
      flask/testsuite/basic.py
  2. 74
      flask/testsuite/blueprints.py
  3. 16
      flask/testsuite/helpers.py
  4. 4
      flask/testsuite/regression.py
  5. 4
      flask/testsuite/reqctx.py
  6. 4
      flask/testsuite/signals.py
  7. 16
      flask/testsuite/templating.py
  8. 8
      flask/testsuite/testing.py
  9. 14
      flask/testsuite/views.py

111
flask/testsuite/basic.py

@ -32,7 +32,7 @@ class BasicFunctionalityTestCase(FlaskTestCase):
return 'Hello World' return 'Hello World'
rv = app.test_client().open('/', method='OPTIONS') rv = app.test_client().open('/', method='OPTIONS')
self.assert_equal(sorted(rv.allow), ['GET', 'HEAD', 'OPTIONS', 'POST']) self.assert_equal(sorted(rv.allow), ['GET', 'HEAD', 'OPTIONS', 'POST'])
self.assert_equal(rv.data, '') self.assert_equal(rv.data, b'')
def test_options_on_multiple_rules(self): def test_options_on_multiple_rules(self):
app = flask.Flask(__name__) app = flask.Flask(__name__)
@ -72,15 +72,15 @@ class BasicFunctionalityTestCase(FlaskTestCase):
return flask.request.method return flask.request.method
c = app.test_client() c = app.test_client()
self.assert_equal(c.get('/').data, 'GET') self.assert_equal(c.get('/').data, b'GET')
rv = c.post('/') rv = c.post('/')
self.assert_equal(rv.status_code, 405) self.assert_equal(rv.status_code, 405)
self.assert_equal(sorted(rv.allow), ['GET', 'HEAD', 'OPTIONS']) self.assert_equal(sorted(rv.allow), ['GET', 'HEAD', 'OPTIONS'])
rv = c.head('/') rv = c.head('/')
self.assert_equal(rv.status_code, 200) self.assert_equal(rv.status_code, 200)
self.assert_(not rv.data) # head truncates self.assert_(not rv.data) # head truncates
self.assert_equal(c.post('/more').data, 'POST') self.assert_equal(c.post('/more').data, b'POST')
self.assert_equal(c.get('/more').data, 'GET') self.assert_equal(c.get('/more').data, b'GET')
rv = c.delete('/more') rv = c.delete('/more')
self.assert_equal(rv.status_code, 405) self.assert_equal(rv.status_code, 405)
self.assert_equal(sorted(rv.allow), ['GET', 'HEAD', 'OPTIONS', 'POST']) self.assert_equal(sorted(rv.allow), ['GET', 'HEAD', 'OPTIONS', 'POST'])
@ -96,15 +96,15 @@ class BasicFunctionalityTestCase(FlaskTestCase):
app.add_url_rule('/more', 'more', more, methods=['GET', 'POST']) app.add_url_rule('/more', 'more', more, methods=['GET', 'POST'])
c = app.test_client() c = app.test_client()
self.assert_equal(c.get('/').data, 'GET') self.assert_equal(c.get('/').data, b'GET')
rv = c.post('/') rv = c.post('/')
self.assert_equal(rv.status_code, 405) self.assert_equal(rv.status_code, 405)
self.assert_equal(sorted(rv.allow), ['GET', 'HEAD', 'OPTIONS']) self.assert_equal(sorted(rv.allow), ['GET', 'HEAD', 'OPTIONS'])
rv = c.head('/') rv = c.head('/')
self.assert_equal(rv.status_code, 200) self.assert_equal(rv.status_code, 200)
self.assert_(not rv.data) # head truncates self.assert_(not rv.data) # head truncates
self.assert_equal(c.post('/more').data, 'POST') self.assert_equal(c.post('/more').data, b'POST')
self.assert_equal(c.get('/more').data, 'GET') self.assert_equal(c.get('/more').data, b'GET')
rv = c.delete('/more') rv = c.delete('/more')
self.assert_equal(rv.status_code, 405) self.assert_equal(rv.status_code, 405)
self.assert_equal(sorted(rv.allow), ['GET', 'HEAD', 'OPTIONS', 'POST']) self.assert_equal(sorted(rv.allow), ['GET', 'HEAD', 'OPTIONS', 'POST'])
@ -124,8 +124,8 @@ class BasicFunctionalityTestCase(FlaskTestCase):
app.view_functions['index'] = index app.view_functions['index'] = index
c = app.test_client() c = app.test_client()
self.assert_equal(c.get('/foo/').data, 'index') self.assert_equal(c.get('/foo/').data, b'index')
self.assert_equal(c.get('/foo/bar').data, 'bar') self.assert_equal(c.get('/foo/bar').data, b'bar')
def test_endpoint_decorator(self): def test_endpoint_decorator(self):
from werkzeug.routing import Submount, Rule from werkzeug.routing import Submount, Rule
@ -144,8 +144,8 @@ class BasicFunctionalityTestCase(FlaskTestCase):
return 'index' return 'index'
c = app.test_client() c = app.test_client()
self.assert_equal(c.get('/foo/').data, 'index') self.assert_equal(c.get('/foo/').data, b'index')
self.assert_equal(c.get('/foo/bar').data, 'bar') self.assert_equal(c.get('/foo/bar').data, b'bar')
def test_session(self): def test_session(self):
app = flask.Flask(__name__) app = flask.Flask(__name__)
@ -159,8 +159,8 @@ class BasicFunctionalityTestCase(FlaskTestCase):
return flask.session['value'] return flask.session['value']
c = app.test_client() c = app.test_client()
self.assert_equal(c.post('/set', data={'value': '42'}).data, 'value set') self.assert_equal(c.post('/set', data={'value': '42'}).data, b'value set')
self.assert_equal(c.get('/get').data, '42') self.assert_equal(c.get('/get').data, b'42')
def test_session_using_server_name(self): def test_session_using_server_name(self):
app = flask.Flask(__name__) app = flask.Flask(__name__)
@ -289,7 +289,7 @@ class BasicFunctionalityTestCase(FlaskTestCase):
self.assert_equal(expires.day, expected.day) self.assert_equal(expires.day, expected.day)
rv = client.get('/test') rv = client.get('/test')
self.assert_equal(rv.data, 'True') self.assert_equal(rv.data, b'True')
permanent = False permanent = False
rv = app.test_client().get('/') rv = app.test_client().get('/')
@ -311,8 +311,8 @@ class BasicFunctionalityTestCase(FlaskTestCase):
return repr(flask.session.get('foo')) return repr(flask.session.get('foo'))
c = app.test_client() c = app.test_client()
self.assert_equal(c.get('/').data, 'None') self.assert_equal(c.get('/').data, b'None')
self.assert_equal(c.get('/').data, '42') self.assert_equal(c.get('/').data, b'42')
def test_session_special_types(self): def test_session_special_types(self):
app = flask.Flask(__name__) app = flask.Flask(__name__)
@ -454,7 +454,7 @@ class BasicFunctionalityTestCase(FlaskTestCase):
self.assert_('after' not in evts) self.assert_('after' not in evts)
rv = app.test_client().get('/').data rv = app.test_client().get('/').data
self.assert_('after' in evts) self.assert_('after' in evts)
self.assert_equal(rv, 'request|after') self.assert_equal(rv, b'request|after')
def test_after_request_processing(self): def test_after_request_processing(self):
app = flask.Flask(__name__) app = flask.Flask(__name__)
@ -483,7 +483,7 @@ class BasicFunctionalityTestCase(FlaskTestCase):
return "Response" return "Response"
rv = app.test_client().get('/') rv = app.test_client().get('/')
self.assert_equal(rv.status_code, 200) self.assert_equal(rv.status_code, 200)
self.assert_('Response' in rv.data) self.assert_(b'Response' in rv.data)
self.assert_equal(len(called), 1) self.assert_equal(len(called), 1)
def test_teardown_request_handler_debug_mode(self): def test_teardown_request_handler_debug_mode(self):
@ -499,7 +499,7 @@ class BasicFunctionalityTestCase(FlaskTestCase):
return "Response" return "Response"
rv = app.test_client().get('/') rv = app.test_client().get('/')
self.assert_equal(rv.status_code, 200) self.assert_equal(rv.status_code, 200)
self.assert_('Response' in rv.data) self.assert_(b'Response' in rv.data)
self.assert_equal(len(called), 1) self.assert_equal(len(called), 1)
def test_teardown_request_handler_error(self): def test_teardown_request_handler_error(self):
@ -532,7 +532,7 @@ class BasicFunctionalityTestCase(FlaskTestCase):
1/0 1/0
rv = app.test_client().get('/') rv = app.test_client().get('/')
self.assert_equal(rv.status_code, 500) self.assert_equal(rv.status_code, 500)
self.assert_('Internal Server Error' in rv.data) self.assert_(b'Internal Server Error' in rv.data)
self.assert_equal(len(called), 2) self.assert_equal(len(called), 2)
def test_before_after_request_order(self): def test_before_after_request_order(self):
@ -562,7 +562,7 @@ class BasicFunctionalityTestCase(FlaskTestCase):
def index(): def index():
return '42' return '42'
rv = app.test_client().get('/') rv = app.test_client().get('/')
self.assert_equal(rv.data, '42') self.assert_equal(rv.data, b'42')
self.assert_equal(called, [1, 2, 3, 4, 5, 6]) self.assert_equal(called, [1, 2, 3, 4, 5, 6])
def test_error_handling(self): def test_error_handling(self):
@ -582,10 +582,10 @@ class BasicFunctionalityTestCase(FlaskTestCase):
c = app.test_client() c = app.test_client()
rv = c.get('/') rv = c.get('/')
self.assert_equal(rv.status_code, 404) self.assert_equal(rv.status_code, 404)
self.assert_equal(rv.data, 'not found') self.assert_equal(rv.data, b'not found')
rv = c.get('/error') rv = c.get('/error')
self.assert_equal(rv.status_code, 500) self.assert_equal(rv.status_code, 500)
self.assert_equal('internal server error', rv.data) self.assert_equal(b'internal server error', rv.data)
def test_before_request_and_routing_errors(self): def test_before_request_and_routing_errors(self):
app = flask.Flask(__name__) app = flask.Flask(__name__)
@ -597,7 +597,7 @@ class BasicFunctionalityTestCase(FlaskTestCase):
return flask.g.something, 404 return flask.g.something, 404
rv = app.test_client().get('/') rv = app.test_client().get('/')
self.assert_equal(rv.status_code, 404) self.assert_equal(rv.status_code, 404)
self.assert_equal(rv.data, 'value') self.assert_equal(rv.data, b'value')
def test_user_error_handling(self): def test_user_error_handling(self):
class MyException(Exception): class MyException(Exception):
@ -613,7 +613,7 @@ class BasicFunctionalityTestCase(FlaskTestCase):
raise MyException() raise MyException()
c = app.test_client() c = app.test_client()
self.assert_equal(c.get('/').data, '42') self.assert_equal(c.get('/').data, b'42')
def test_trapping_of_bad_request_key_errors(self): def test_trapping_of_bad_request_key_errors(self):
app = flask.Flask(__name__) app = flask.Flask(__name__)
@ -687,7 +687,7 @@ class BasicFunctionalityTestCase(FlaskTestCase):
self.assert_equal(c.get('/unicode').data, u'Hällo Wörld'.encode('utf-8')) self.assert_equal(c.get('/unicode').data, u'Hällo Wörld'.encode('utf-8'))
self.assert_equal(c.get('/string').data, u'Hällo Wörld'.encode('utf-8')) self.assert_equal(c.get('/string').data, u'Hällo Wörld'.encode('utf-8'))
rv = c.get('/args') rv = c.get('/args')
self.assert_equal(rv.data, 'Meh') self.assert_equal(rv.data, b'Meh')
self.assert_equal(rv.headers['X-Foo'], 'Testing') self.assert_equal(rv.headers['X-Foo'], 'Testing')
self.assert_equal(rv.status_code, 400) self.assert_equal(rv.status_code, 400)
self.assert_equal(rv.mimetype, 'text/plain') self.assert_equal(rv.mimetype, 'text/plain')
@ -697,17 +697,17 @@ class BasicFunctionalityTestCase(FlaskTestCase):
with app.test_request_context(): with app.test_request_context():
rv = flask.make_response() rv = flask.make_response()
self.assert_equal(rv.status_code, 200) self.assert_equal(rv.status_code, 200)
self.assert_equal(rv.data, '') self.assert_equal(rv.data, b'')
self.assert_equal(rv.mimetype, 'text/html') self.assert_equal(rv.mimetype, 'text/html')
rv = flask.make_response('Awesome') rv = flask.make_response('Awesome')
self.assert_equal(rv.status_code, 200) self.assert_equal(rv.status_code, 200)
self.assert_equal(rv.data, 'Awesome') self.assert_equal(rv.data, b'Awesome')
self.assert_equal(rv.mimetype, 'text/html') self.assert_equal(rv.mimetype, 'text/html')
rv = flask.make_response('W00t', 404) rv = flask.make_response('W00t', 404)
self.assert_equal(rv.status_code, 404) self.assert_equal(rv.status_code, 404)
self.assert_equal(rv.data, 'W00t') self.assert_equal(rv.data, b'W00t')
self.assert_equal(rv.mimetype, 'text/html') self.assert_equal(rv.mimetype, 'text/html')
def test_make_response_with_response_instance(self): def test_make_response_with_response_instance(self):
@ -716,14 +716,13 @@ class BasicFunctionalityTestCase(FlaskTestCase):
rv = flask.make_response( rv = flask.make_response(
flask.jsonify({'msg': 'W00t'}), 400) flask.jsonify({'msg': 'W00t'}), 400)
self.assertEqual(rv.status_code, 400) self.assertEqual(rv.status_code, 400)
self.assertEqual(rv.data, self.assertEqual(rv.data, b'{\n "msg": "W00t"\n}')
'{\n "msg": "W00t"\n}')
self.assertEqual(rv.mimetype, 'application/json') self.assertEqual(rv.mimetype, 'application/json')
rv = flask.make_response( rv = flask.make_response(
flask.Response(''), 400) flask.Response(''), 400)
self.assertEqual(rv.status_code, 400) self.assertEqual(rv.status_code, 400)
self.assertEqual(rv.data, '') self.assertEqual(rv.data, b'')
self.assertEqual(rv.mimetype, 'text/html') self.assertEqual(rv.mimetype, 'text/html')
rv = flask.make_response( rv = flask.make_response(
@ -783,13 +782,13 @@ class BasicFunctionalityTestCase(FlaskTestCase):
def index(args): def index(args):
return '|'.join(args) return '|'.join(args)
c = app.test_client() c = app.test_client()
self.assert_equal(c.get('/1,2,3').data, '1|2|3') self.assert_equal(c.get('/1,2,3').data, b'1|2|3')
def test_static_files(self): def test_static_files(self):
app = flask.Flask(__name__) app = flask.Flask(__name__)
rv = app.test_client().get('/static/index.html') rv = app.test_client().get('/static/index.html')
self.assert_equal(rv.status_code, 200) self.assert_equal(rv.status_code, 200)
self.assert_equal(rv.data.strip(), '<h1>Hello World!</h1>') self.assert_equal(rv.data.strip(), b'<h1>Hello World!</h1>')
with app.test_request_context(): with app.test_request_context():
self.assert_equal(flask.url_for('static', filename='index.html'), self.assert_equal(flask.url_for('static', filename='index.html'),
'/static/index.html') '/static/index.html')
@ -825,17 +824,17 @@ class BasicFunctionalityTestCase(FlaskTestCase):
return 'Foo SubDomain' return 'Foo SubDomain'
rv = app.test_client().get('/') rv = app.test_client().get('/')
self.assert_equal(rv.data, 'Foo') self.assert_equal(rv.data, b'Foo')
rv = app.test_client().get('/', 'http://localhost.localdomain:5000') rv = app.test_client().get('/', 'http://localhost.localdomain:5000')
self.assert_equal(rv.data, 'Foo') self.assert_equal(rv.data, b'Foo')
rv = app.test_client().get('/', 'https://localhost.localdomain:5000') rv = app.test_client().get('/', 'https://localhost.localdomain:5000')
self.assert_equal(rv.data, 'Foo') self.assert_equal(rv.data, b'Foo')
app.config.update(SERVER_NAME='localhost.localdomain') app.config.update(SERVER_NAME='localhost.localdomain')
rv = app.test_client().get('/', 'https://localhost.localdomain') rv = app.test_client().get('/', 'https://localhost.localdomain')
self.assert_equal(rv.data, 'Foo') self.assert_equal(rv.data, b'Foo')
try: try:
app.config.update(SERVER_NAME='localhost.localdomain:443') app.config.update(SERVER_NAME='localhost.localdomain:443')
@ -860,7 +859,7 @@ class BasicFunctionalityTestCase(FlaskTestCase):
"server name from the WSGI environment ('foo.localhost')") "server name from the WSGI environment ('foo.localhost')")
rv = app.test_client().get('/', 'http://foo.localhost.localdomain') rv = app.test_client().get('/', 'http://foo.localhost.localdomain')
self.assert_equal(rv.data, 'Foo SubDomain') self.assert_equal(rv.data, b'Foo SubDomain')
def test_exception_propagation(self): def test_exception_propagation(self):
def apprunner(configkey): def apprunner(configkey):
@ -906,7 +905,7 @@ class BasicFunctionalityTestCase(FlaskTestCase):
c = app.test_client() c = app.test_client()
rv = c.post('/accept', data={'myfile': 'foo' * 100}) rv = c.post('/accept', data={'myfile': 'foo' * 100})
self.assert_equal(rv.data, '42') self.assert_equal(rv.data, b'42')
def test_url_processors(self): def test_url_processors(self):
app = flask.Flask(__name__) app = flask.Flask(__name__)
@ -935,9 +934,9 @@ class BasicFunctionalityTestCase(FlaskTestCase):
c = app.test_client() c = app.test_client()
self.assert_equal(c.get('/de/').data, '/de/about') self.assert_equal(c.get('/de/').data, b'/de/about')
self.assert_equal(c.get('/de/about').data, '/foo') self.assert_equal(c.get('/de/about').data, b'/foo')
self.assert_equal(c.get('/foo').data, '/en/about') self.assert_equal(c.get('/foo').data, b'/en/about')
def test_inject_blueprint_url_defaults(self): def test_inject_blueprint_url_defaults(self):
app = flask.Flask(__name__) app = flask.Flask(__name__)
@ -969,7 +968,7 @@ class BasicFunctionalityTestCase(FlaskTestCase):
def index(): def index():
return 'Awesome' return 'Awesome'
self.assert_(not app.got_first_request) self.assert_(not app.got_first_request)
self.assert_equal(app.test_client().get('/').data, 'Awesome') self.assert_equal(app.test_client().get('/').data, b'Awesome')
try: try:
@app.route('/foo') @app.route('/foo')
def broken(): def broken():
@ -983,7 +982,7 @@ class BasicFunctionalityTestCase(FlaskTestCase):
@app.route('/foo') @app.route('/foo')
def working(): def working():
return 'Meh' return 'Meh'
self.assert_equal(app.test_client().get('/foo').data, 'Meh') self.assert_equal(app.test_client().get('/foo').data, b'Meh')
self.assert_(app.got_first_request) self.assert_(app.got_first_request)
def test_before_first_request_functions(self): def test_before_first_request_functions(self):
@ -1016,12 +1015,12 @@ class BasicFunctionalityTestCase(FlaskTestCase):
self.fail('Expected exception') self.fail('Expected exception')
rv = c.get('/foo', data={}, follow_redirects=True) rv = c.get('/foo', data={}, follow_redirects=True)
self.assert_equal(rv.data, 'success') self.assert_equal(rv.data, b'success')
app.debug = False app.debug = False
with app.test_client() as c: with app.test_client() as c:
rv = c.post('/foo', data={}, follow_redirects=True) rv = c.post('/foo', data={}, follow_redirects=True)
self.assert_equal(rv.data, 'success') self.assert_equal(rv.data, b'success')
def test_route_decorator_custom_endpoint(self): def test_route_decorator_custom_endpoint(self):
app = flask.Flask(__name__) app = flask.Flask(__name__)
@ -1045,9 +1044,9 @@ class BasicFunctionalityTestCase(FlaskTestCase):
assert flask.url_for('123') == '/bar/123' assert flask.url_for('123') == '/bar/123'
c = app.test_client() c = app.test_client()
self.assertEqual(c.get('/foo/').data, 'foo') self.assertEqual(c.get('/foo/').data, b'foo')
self.assertEqual(c.get('/bar/').data, 'bar') self.assertEqual(c.get('/bar/').data, b'bar')
self.assertEqual(c.get('/bar/123').data, '123') self.assertEqual(c.get('/bar/123').data, b'123')
def test_preserve_only_once(self): def test_preserve_only_once(self):
app = flask.Flask(__name__) app = flask.Flask(__name__)
@ -1084,10 +1083,10 @@ class SubdomainTestCase(FlaskTestCase):
c = app.test_client() c = app.test_client()
rv = c.get('/', 'http://localhost/') rv = c.get('/', 'http://localhost/')
self.assert_equal(rv.data, 'normal index') self.assert_equal(rv.data, b'normal index')
rv = c.get('/', 'http://test.localhost/') rv = c.get('/', 'http://test.localhost/')
self.assert_equal(rv.data, 'test index') self.assert_equal(rv.data, b'test index')
@emits_module_deprecation_warning @emits_module_deprecation_warning
def test_module_static_path_subdomain(self): def test_module_static_path_subdomain(self):
@ -1108,7 +1107,7 @@ class SubdomainTestCase(FlaskTestCase):
c = app.test_client() c = app.test_client()
rv = c.get('/', 'http://mitsuhiko.localhost/') rv = c.get('/', 'http://mitsuhiko.localhost/')
self.assert_equal(rv.data, 'index for mitsuhiko') self.assert_equal(rv.data, b'index for mitsuhiko')
def test_subdomain_matching_with_ports(self): def test_subdomain_matching_with_ports(self):
app = flask.Flask(__name__) app = flask.Flask(__name__)
@ -1119,7 +1118,7 @@ class SubdomainTestCase(FlaskTestCase):
c = app.test_client() c = app.test_client()
rv = c.get('/', 'http://mitsuhiko.localhost:3000/') rv = c.get('/', 'http://mitsuhiko.localhost:3000/')
self.assert_equal(rv.data, 'index for mitsuhiko') self.assert_equal(rv.data, b'index for mitsuhiko')
@emits_module_deprecation_warning @emits_module_deprecation_warning
def test_module_subdomain_support(self): def test_module_subdomain_support(self):
@ -1139,9 +1138,9 @@ class SubdomainTestCase(FlaskTestCase):
c = app.test_client() c = app.test_client()
rv = c.get('/test', 'http://testing.localhost/') rv = c.get('/test', 'http://testing.localhost/')
self.assert_equal(rv.data, 'Test') self.assert_equal(rv.data, b'Test')
rv = c.get('/outside', 'http://xtesting.localhost/') rv = c.get('/outside', 'http://xtesting.localhost/')
self.assert_equal(rv.data, 'Outside') self.assert_equal(rv.data, b'Outside')
def suite(): def suite():

74
flask/testsuite/blueprints.py

@ -46,10 +46,10 @@ class ModuleTestCase(FlaskTestCase):
return 'the index' return 'the index'
app.register_module(admin) app.register_module(admin)
c = app.test_client() c = app.test_client()
self.assert_equal(c.get('/').data, 'the index') self.assert_equal(c.get('/').data, b'the index')
self.assert_equal(c.get('/admin/').data, 'admin index') self.assert_equal(c.get('/admin/').data, b'admin index')
self.assert_equal(c.get('/admin/login').data, 'admin login') self.assert_equal(c.get('/admin/login').data, b'admin login')
self.assert_equal(c.get('/admin/logout').data, 'admin logout') self.assert_equal(c.get('/admin/logout').data, b'admin logout')
@emits_module_deprecation_warning @emits_module_deprecation_warning
def test_default_endpoint_name(self): def test_default_endpoint_name(self):
@ -60,7 +60,7 @@ class ModuleTestCase(FlaskTestCase):
mod.add_url_rule('/', view_func=index) mod.add_url_rule('/', view_func=index)
app.register_module(mod) app.register_module(mod)
rv = app.test_client().get('/') rv = app.test_client().get('/')
self.assert_equal(rv.data, 'Awesome') self.assert_equal(rv.data, b'Awesome')
with app.test_request_context(): with app.test_request_context():
self.assert_equal(flask.url_for('frontend.index'), '/') self.assert_equal(flask.url_for('frontend.index'), '/')
@ -92,11 +92,11 @@ class ModuleTestCase(FlaskTestCase):
app.register_module(admin) app.register_module(admin)
c = app.test_client() c = app.test_client()
self.assert_equal(c.get('/').data, 'the index') self.assert_equal(c.get('/').data, b'the index')
self.assert_equal(catched, ['before-app', 'after-app']) self.assert_equal(catched, ['before-app', 'after-app'])
del catched[:] del catched[:]
self.assert_equal(c.get('/admin/').data, 'the admin') self.assert_equal(c.get('/admin/').data, b'the admin')
self.assert_equal(catched, ['before-app', 'before-admin', self.assert_equal(catched, ['before-app', 'before-admin',
'after-admin', 'after-app']) 'after-admin', 'after-app'])
@ -121,8 +121,8 @@ class ModuleTestCase(FlaskTestCase):
return flask.render_template_string('{{ a }}{{ b }}{{ c }}') return flask.render_template_string('{{ a }}{{ b }}{{ c }}')
app.register_module(admin) app.register_module(admin)
c = app.test_client() c = app.test_client()
self.assert_equal(c.get('/').data, '13') self.assert_equal(c.get('/').data, b'13')
self.assert_equal(c.get('/admin/').data, '123') self.assert_equal(c.get('/admin/').data, b'123')
@emits_module_deprecation_warning @emits_module_deprecation_warning
def test_late_binding(self): def test_late_binding(self):
@ -132,7 +132,7 @@ class ModuleTestCase(FlaskTestCase):
def index(): def index():
return '42' return '42'
app.register_module(admin, url_prefix='/admin') app.register_module(admin, url_prefix='/admin')
self.assert_equal(app.test_client().get('/admin/').data, '42') self.assert_equal(app.test_client().get('/admin/').data, b'42')
@emits_module_deprecation_warning @emits_module_deprecation_warning
def test_error_handling(self): def test_error_handling(self):
@ -154,7 +154,7 @@ class ModuleTestCase(FlaskTestCase):
c = app.test_client() c = app.test_client()
rv = c.get('/') rv = c.get('/')
self.assert_equal(rv.status_code, 404) self.assert_equal(rv.status_code, 404)
self.assert_equal(rv.data, 'not found') self.assert_equal(rv.data, b'not found')
rv = c.get('/error') rv = c.get('/error')
self.assert_equal(rv.status_code, 500) self.assert_equal(rv.status_code, 500)
self.assert_equal('internal server error', rv.data) self.assert_equal('internal server error', rv.data)
@ -165,11 +165,11 @@ class ModuleTestCase(FlaskTestCase):
c = app.test_client() c = app.test_client()
rv = c.get('/') rv = c.get('/')
self.assert_equal(rv.data, 'Hello from the Frontend') self.assert_equal(rv.data, b'Hello from the Frontend')
rv = c.get('/admin/') rv = c.get('/admin/')
self.assert_equal(rv.data, 'Hello from the Admin') self.assert_equal(rv.data, b'Hello from the Admin')
rv = c.get('/admin/index2') rv = c.get('/admin/index2')
self.assert_equal(rv.data, 'Hello from the Admin') self.assert_equal(rv.data, b'Hello from the Admin')
rv = c.get('/admin/static/test.txt') rv = c.get('/admin/static/test.txt')
self.assert_equal(rv.data.strip(), 'Admin File') self.assert_equal(rv.data.strip(), 'Admin File')
rv = c.get('/admin/static/css/test.css') rv = c.get('/admin/static/css/test.css')
@ -248,8 +248,8 @@ class ModuleTestCase(FlaskTestCase):
app.register_module(module) app.register_module(module)
c = app.test_client() c = app.test_client()
self.assert_equal(c.get('/foo/').data, 'index') self.assert_equal(c.get('/foo/').data, b'index')
self.assert_equal(c.get('/foo/bar').data, 'bar') self.assert_equal(c.get('/foo/bar').data, b'bar')
class BlueprintTestCase(FlaskTestCase): class BlueprintTestCase(FlaskTestCase):
@ -290,9 +290,9 @@ class BlueprintTestCase(FlaskTestCase):
c = app.test_client() c = app.test_client()
self.assert_equal(c.get('/frontend-no').data, 'frontend says no') self.assert_equal(c.get('/frontend-no').data, b'frontend says no')
self.assert_equal(c.get('/backend-no').data, 'backend says no') self.assert_equal(c.get('/backend-no').data, b'backend says no')
self.assert_equal(c.get('/what-is-a-sideend').data, 'application itself says no') self.assert_equal(c.get('/what-is-a-sideend').data, b'application itself says no')
def test_blueprint_url_definitions(self): def test_blueprint_url_definitions(self):
bp = flask.Blueprint('test', __name__) bp = flask.Blueprint('test', __name__)
@ -339,19 +339,19 @@ class BlueprintTestCase(FlaskTestCase):
c = app.test_client() c = app.test_client()
self.assert_equal(c.get('/de/').data, '/de/about') self.assert_equal(c.get('/de/').data, b'/de/about')
self.assert_equal(c.get('/de/about').data, '/de/') self.assert_equal(c.get('/de/about').data, b'/de/')
def test_templates_and_static(self): def test_templates_and_static(self):
from blueprintapp import app from blueprintapp import app
c = app.test_client() c = app.test_client()
rv = c.get('/') rv = c.get('/')
self.assert_equal(rv.data, 'Hello from the Frontend') self.assert_equal(rv.data, b'Hello from the Frontend')
rv = c.get('/admin/') rv = c.get('/admin/')
self.assert_equal(rv.data, 'Hello from the Admin') self.assert_equal(rv.data, b'Hello from the Admin')
rv = c.get('/admin/index2') rv = c.get('/admin/index2')
self.assert_equal(rv.data, 'Hello from the Admin') self.assert_equal(rv.data, b'Hello from the Admin')
rv = c.get('/admin/static/test.txt') rv = c.get('/admin/static/test.txt')
self.assert_equal(rv.data.strip(), 'Admin File') self.assert_equal(rv.data.strip(), 'Admin File')
rv = c.get('/admin/static/css/test.css') rv = c.get('/admin/static/css/test.css')
@ -451,8 +451,8 @@ class BlueprintTestCase(FlaskTestCase):
app.register_blueprint(bp) app.register_blueprint(bp)
c = app.test_client() c = app.test_client()
self.assert_equal(c.get('/').data, '1') self.assert_equal(c.get('/').data, b'1')
self.assert_equal(c.get('/page/2').data, '2') self.assert_equal(c.get('/page/2').data, b'2')
def test_route_decorator_custom_endpoint(self): def test_route_decorator_custom_endpoint(self):
@ -482,11 +482,11 @@ class BlueprintTestCase(FlaskTestCase):
return flask.request.endpoint return flask.request.endpoint
c = app.test_client() c = app.test_client()
self.assertEqual(c.get('/').data, 'index') self.assertEqual(c.get('/').data, b'index')
self.assertEqual(c.get('/py/foo').data, 'bp.foo') self.assertEqual(c.get('/py/foo').data, b'bp.foo')
self.assertEqual(c.get('/py/bar').data, 'bp.bar') self.assertEqual(c.get('/py/bar').data, b'bp.bar')
self.assertEqual(c.get('/py/bar/123').data, 'bp.123') self.assertEqual(c.get('/py/bar/123').data, b'bp.123')
self.assertEqual(c.get('/py/bar/foo').data, 'bp.bar_foo') self.assertEqual(c.get('/py/bar/foo').data, b'bp.bar_foo')
def test_route_decorator_custom_endpoint_with_dots(self): def test_route_decorator_custom_endpoint_with_dots(self):
bp = flask.Blueprint('bp', __name__) bp = flask.Blueprint('bp', __name__)
@ -533,7 +533,7 @@ class BlueprintTestCase(FlaskTestCase):
app.register_blueprint(bp, url_prefix='/py') app.register_blueprint(bp, url_prefix='/py')
c = app.test_client() c = app.test_client()
self.assertEqual(c.get('/py/foo').data, 'bp.foo') self.assertEqual(c.get('/py/foo').data, b'bp.foo')
# The rule's din't actually made it through # The rule's din't actually made it through
rv = c.get('/py/bar') rv = c.get('/py/bar')
assert rv.status_code == 404 assert rv.status_code == 404
@ -595,7 +595,7 @@ class BlueprintTestCase(FlaskTestCase):
def index(): def index():
return flask.render_template('template_filter.html', value='abcd') return flask.render_template('template_filter.html', value='abcd')
rv = app.test_client().get('/') rv = app.test_client().get('/')
self.assert_equal(rv.data, 'dcba') self.assert_equal(rv.data, b'dcba')
def test_template_filter_after_route_with_template(self): def test_template_filter_after_route_with_template(self):
app = flask.Flask(__name__) app = flask.Flask(__name__)
@ -608,7 +608,7 @@ class BlueprintTestCase(FlaskTestCase):
return s[::-1] return s[::-1]
app.register_blueprint(bp, url_prefix='/py') app.register_blueprint(bp, url_prefix='/py')
rv = app.test_client().get('/') rv = app.test_client().get('/')
self.assert_equal(rv.data, 'dcba') self.assert_equal(rv.data, b'dcba')
def test_add_template_filter_with_template(self): def test_add_template_filter_with_template(self):
bp = flask.Blueprint('bp', __name__) bp = flask.Blueprint('bp', __name__)
@ -621,7 +621,7 @@ class BlueprintTestCase(FlaskTestCase):
def index(): def index():
return flask.render_template('template_filter.html', value='abcd') return flask.render_template('template_filter.html', value='abcd')
rv = app.test_client().get('/') rv = app.test_client().get('/')
self.assert_equal(rv.data, 'dcba') self.assert_equal(rv.data, b'dcba')
def test_template_filter_with_name_and_template(self): def test_template_filter_with_name_and_template(self):
bp = flask.Blueprint('bp', __name__) bp = flask.Blueprint('bp', __name__)
@ -634,7 +634,7 @@ class BlueprintTestCase(FlaskTestCase):
def index(): def index():
return flask.render_template('template_filter.html', value='abcd') return flask.render_template('template_filter.html', value='abcd')
rv = app.test_client().get('/') rv = app.test_client().get('/')
self.assert_equal(rv.data, 'dcba') self.assert_equal(rv.data, b'dcba')
def test_add_template_filter_with_name_and_template(self): def test_add_template_filter_with_name_and_template(self):
bp = flask.Blueprint('bp', __name__) bp = flask.Blueprint('bp', __name__)
@ -647,7 +647,7 @@ class BlueprintTestCase(FlaskTestCase):
def index(): def index():
return flask.render_template('template_filter.html', value='abcd') return flask.render_template('template_filter.html', value='abcd')
rv = app.test_client().get('/') rv = app.test_client().get('/')
self.assert_equal(rv.data, 'dcba') self.assert_equal(rv.data, b'dcba')
def test_template_test(self): def test_template_test(self):
bp = flask.Blueprint('bp', __name__) bp = flask.Blueprint('bp', __name__)

16
flask/testsuite/helpers.py

@ -99,7 +99,7 @@ class JSONTestCase(FlaskTestCase):
c = app.test_client() c = app.test_client()
rv = c.post('/add', data=flask.json.dumps({'a': 1, 'b': 2}), rv = c.post('/add', data=flask.json.dumps({'a': 1, 'b': 2}),
content_type='application/json') content_type='application/json')
self.assert_equal(rv.data, '3') self.assert_equal(rv.data, b'3')
def test_template_escaping(self): def test_template_escaping(self):
app = flask.Flask(__name__) app = flask.Flask(__name__)
@ -140,7 +140,7 @@ class JSONTestCase(FlaskTestCase):
rv = c.post('/', data=flask.json.dumps({ rv = c.post('/', data=flask.json.dumps({
'x': {'_foo': 42} 'x': {'_foo': 42}
}), content_type='application/json') }), content_type='application/json')
self.assertEqual(rv.data, '"<42>"') self.assertEqual(rv.data, b'"<42>"')
def test_modified_url_encoding(self): def test_modified_url_encoding(self):
class ModifiedRequest(flask.Request): class ModifiedRequest(flask.Request):
@ -212,14 +212,14 @@ class SendfileTestCase(FlaskTestCase):
with catch_warnings() as captured: with catch_warnings() as captured:
f = StringIO('Test') f = StringIO('Test')
rv = flask.send_file(f) rv = flask.send_file(f)
self.assert_equal(rv.data, 'Test') self.assert_equal(rv.data, b'Test')
self.assert_equal(rv.mimetype, 'application/octet-stream') self.assert_equal(rv.mimetype, 'application/octet-stream')
# etags # etags
self.assert_equal(len(captured), 1) self.assert_equal(len(captured), 1)
with catch_warnings() as captured: with catch_warnings() as captured:
f = StringIO('Test') f = StringIO('Test')
rv = flask.send_file(f, mimetype='text/plain') rv = flask.send_file(f, mimetype='text/plain')
self.assert_equal(rv.data, 'Test') self.assert_equal(rv.data, b'Test')
self.assert_equal(rv.mimetype, 'text/plain') self.assert_equal(rv.mimetype, 'text/plain')
# etags # etags
self.assert_equal(len(captured), 1) self.assert_equal(len(captured), 1)
@ -385,7 +385,7 @@ class LoggingTestCase(FlaskTestCase):
for trigger in 'before', 'after': for trigger in 'before', 'after':
rv = app.test_client().get('/') rv = app.test_client().get('/')
self.assert_equal(rv.status_code, 500) self.assert_equal(rv.status_code, 500)
self.assert_equal(rv.data, 'Hello Server Error') self.assert_equal(rv.data, b'Hello Server Error')
def test_url_for_with_anchor(self): def test_url_for_with_anchor(self):
app = flask.Flask(__name__) app = flask.Flask(__name__)
@ -477,7 +477,7 @@ class StreamingTestCase(FlaskTestCase):
return flask.Response(flask.stream_with_context(generate())) return flask.Response(flask.stream_with_context(generate()))
c = app.test_client() c = app.test_client()
rv = c.get('/?name=World') rv = c.get('/?name=World')
self.assertEqual(rv.data, 'Hello World!') self.assertEqual(rv.data, b'Hello World!')
def test_streaming_with_context_as_decorator(self): def test_streaming_with_context_as_decorator(self):
app = flask.Flask(__name__) app = flask.Flask(__name__)
@ -492,7 +492,7 @@ class StreamingTestCase(FlaskTestCase):
return flask.Response(generate()) return flask.Response(generate())
c = app.test_client() c = app.test_client()
rv = c.get('/?name=World') rv = c.get('/?name=World')
self.assertEqual(rv.data, 'Hello World!') self.assertEqual(rv.data, b'Hello World!')
def test_streaming_with_context_and_custom_close(self): def test_streaming_with_context_and_custom_close(self):
app = flask.Flask(__name__) app = flask.Flask(__name__)
@ -517,7 +517,7 @@ class StreamingTestCase(FlaskTestCase):
Wrapper(generate()))) Wrapper(generate())))
c = app.test_client() c = app.test_client()
rv = c.get('/?name=World') rv = c.get('/?name=World')
self.assertEqual(rv.data, 'Hello World!') self.assertEqual(rv.data, b'Hello World!')
self.assertEqual(called, [42]) self.assertEqual(called, [42])

4
flask/testsuite/regression.py

@ -66,7 +66,7 @@ class MemoryTestCase(FlaskTestCase):
with app.test_client() as c: with app.test_client() as c:
rv = c.get('/') rv = c.get('/')
self.assert_equal(rv.status_code, 200) self.assert_equal(rv.status_code, 200)
self.assert_equal(rv.data, '<h1>42</h1>') self.assert_equal(rv.data, b'<h1>42</h1>')
# Trigger caches # Trigger caches
fire() fire()
@ -105,7 +105,7 @@ class ExceptionTestCase(FlaskTestCase):
rv = c.get('/') rv = c.get('/')
self.assertEqual(rv.headers['Location'], 'http://localhost/test') self.assertEqual(rv.headers['Location'], 'http://localhost/test')
rv = c.get('/test') rv = c.get('/test')
self.assertEqual(rv.data, '42') self.assertEqual(rv.data, b'42')
def suite(): def suite():

4
flask/testsuite/reqctx.py

@ -145,7 +145,7 @@ class RequestContextTestCase(FlaskTestCase):
return 'Hello World!' return 'Hello World!'
rv = app.test_client().get('/?foo=bar') rv = app.test_client().get('/?foo=bar')
self.assert_equal(rv.data, 'Hello World!') self.assert_equal(rv.data, b'Hello World!')
result = greenlets[0].run() result = greenlets[0].run()
self.assert_equal(result, 42) self.assert_equal(result, 42)
@ -168,7 +168,7 @@ class RequestContextTestCase(FlaskTestCase):
return 'Hello World!' return 'Hello World!'
rv = app.test_client().get('/?foo=bar') rv = app.test_client().get('/?foo=bar')
self.assert_equal(rv.data, 'Hello World!') self.assert_equal(rv.data, b'Hello World!')
result = greenlets[0].run() result = greenlets[0].run()
self.assert_equal(result, 42) self.assert_equal(result, 42)

4
flask/testsuite/signals.py

@ -45,7 +45,7 @@ class SignalsTestCase(FlaskTestCase):
calls.append('before-signal') calls.append('before-signal')
def after_request_signal(sender, response): def after_request_signal(sender, response):
self.assert_equal(response.data, 'stuff') self.assert_equal(response.data, b'stuff')
calls.append('after-signal') calls.append('after-signal')
@app.before_request @app.before_request
@ -68,7 +68,7 @@ class SignalsTestCase(FlaskTestCase):
try: try:
rv = app.test_client().get('/') rv = app.test_client().get('/')
self.assert_equal(rv.data, 'stuff') self.assert_equal(rv.data, b'stuff')
self.assert_equal(calls, ['before-signal', 'before-handler', self.assert_equal(calls, ['before-signal', 'before-handler',
'handler', 'after-handler', 'handler', 'after-handler',

16
flask/testsuite/templating.py

@ -25,7 +25,7 @@ class TemplatingTestCase(FlaskTestCase):
def index(): def index():
return flask.render_template('context_template.html', value=23) return flask.render_template('context_template.html', value=23)
rv = app.test_client().get('/') rv = app.test_client().get('/')
self.assert_equal(rv.data, '<p>23|42') self.assert_equal(rv.data, b'<p>23|42')
def test_original_win(self): def test_original_win(self):
app = flask.Flask(__name__) app = flask.Flask(__name__)
@ -33,7 +33,7 @@ class TemplatingTestCase(FlaskTestCase):
def index(): def index():
return flask.render_template_string('{{ config }}', config=42) return flask.render_template_string('{{ config }}', config=42)
rv = app.test_client().get('/') rv = app.test_client().get('/')
self.assert_equal(rv.data, '42') self.assert_equal(rv.data, b'42')
def test_request_less_rendering(self): def test_request_less_rendering(self):
app = flask.Flask(__name__) app = flask.Flask(__name__)
@ -139,7 +139,7 @@ class TemplatingTestCase(FlaskTestCase):
def index(): def index():
return flask.render_template('template_filter.html', value='abcd') return flask.render_template('template_filter.html', value='abcd')
rv = app.test_client().get('/') rv = app.test_client().get('/')
self.assert_equal(rv.data, 'dcba') self.assert_equal(rv.data, b'dcba')
def test_add_template_filter_with_template(self): def test_add_template_filter_with_template(self):
app = flask.Flask(__name__) app = flask.Flask(__name__)
@ -150,7 +150,7 @@ class TemplatingTestCase(FlaskTestCase):
def index(): def index():
return flask.render_template('template_filter.html', value='abcd') return flask.render_template('template_filter.html', value='abcd')
rv = app.test_client().get('/') rv = app.test_client().get('/')
self.assert_equal(rv.data, 'dcba') self.assert_equal(rv.data, b'dcba')
def test_template_filter_with_name_and_template(self): def test_template_filter_with_name_and_template(self):
app = flask.Flask(__name__) app = flask.Flask(__name__)
@ -161,7 +161,7 @@ class TemplatingTestCase(FlaskTestCase):
def index(): def index():
return flask.render_template('template_filter.html', value='abcd') return flask.render_template('template_filter.html', value='abcd')
rv = app.test_client().get('/') rv = app.test_client().get('/')
self.assert_equal(rv.data, 'dcba') self.assert_equal(rv.data, b'dcba')
def test_add_template_filter_with_name_and_template(self): def test_add_template_filter_with_name_and_template(self):
app = flask.Flask(__name__) app = flask.Flask(__name__)
@ -172,7 +172,7 @@ class TemplatingTestCase(FlaskTestCase):
def index(): def index():
return flask.render_template('template_filter.html', value='abcd') return flask.render_template('template_filter.html', value='abcd')
rv = app.test_client().get('/') rv = app.test_client().get('/')
self.assert_equal(rv.data, 'dcba') self.assert_equal(rv.data, b'dcba')
def test_template_test(self): def test_template_test(self):
app = flask.Flask(__name__) app = flask.Flask(__name__)
@ -277,7 +277,7 @@ class TemplatingTestCase(FlaskTestCase):
return flask.render_template('index.html') return flask.render_template('index.html')
c = app.test_client() c = app.test_client()
rv = c.get('/') rv = c.get('/')
self.assert_equal(rv.data, 'Hello Custom World!') self.assert_equal(rv.data, b'Hello Custom World!')
def test_iterable_loader(self): def test_iterable_loader(self):
app = flask.Flask(__name__) app = flask.Flask(__name__)
@ -293,7 +293,7 @@ class TemplatingTestCase(FlaskTestCase):
value=23) value=23)
rv = app.test_client().get('/') rv = app.test_client().get('/')
self.assert_equal(rv.data, '<h1>Jameson</h1>') self.assert_equal(rv.data, b'<h1>Jameson</h1>')
def suite(): def suite():

8
flask/testsuite/testing.py

@ -30,7 +30,7 @@ class TestToolsTestCase(FlaskTestCase):
self.assert_equal(ctx.request.url, 'http://example.com:1234/foo/') self.assert_equal(ctx.request.url, 'http://example.com:1234/foo/')
with app.test_client() as c: with app.test_client() as c:
rv = c.get('/') rv = c.get('/')
self.assert_equal(rv.data, 'http://example.com:1234/foo/') self.assert_equal(rv.data, b'http://example.com:1234/foo/')
def test_environ_defaults(self): def test_environ_defaults(self):
app = flask.Flask(__name__) app = flask.Flask(__name__)
@ -43,7 +43,7 @@ class TestToolsTestCase(FlaskTestCase):
self.assert_equal(ctx.request.url, 'http://localhost/') self.assert_equal(ctx.request.url, 'http://localhost/')
with app.test_client() as c: with app.test_client() as c:
rv = c.get('/') rv = c.get('/')
self.assert_equal(rv.data, 'http://localhost/') self.assert_equal(rv.data, b'http://localhost/')
def test_redirect_keep_session(self): def test_redirect_keep_session(self):
app = flask.Flask(__name__) app = flask.Flask(__name__)
@ -92,7 +92,7 @@ class TestToolsTestCase(FlaskTestCase):
sess['foo'] = [42] sess['foo'] = [42]
self.assert_equal(len(sess), 1) self.assert_equal(len(sess), 1)
rv = c.get('/') rv = c.get('/')
self.assert_equal(rv.data, '[42]') self.assert_equal(rv.data, b'[42]')
with c.session_transaction() as sess: with c.session_transaction() as sess:
self.assert_equal(len(sess), 1) self.assert_equal(len(sess), 1)
self.assert_equal(sess['foo'], [42]) self.assert_equal(sess['foo'], [42])
@ -148,7 +148,7 @@ class TestToolsTestCase(FlaskTestCase):
with app.test_client() as c: with app.test_client() as c:
resp = c.get('/') resp = c.get('/')
self.assert_equal(flask.g.value, 42) self.assert_equal(flask.g.value, 42)
self.assert_equal(resp.data, 'Hello World!') self.assert_equal(resp.data, b'Hello World!')
self.assert_equal(resp.status_code, 200) self.assert_equal(resp.status_code, 200)
resp = c.get('/other') resp = c.get('/other')

14
flask/testsuite/views.py

@ -20,8 +20,8 @@ class ViewTestCase(FlaskTestCase):
def common_test(self, app): def common_test(self, app):
c = app.test_client() c = app.test_client()
self.assert_equal(c.get('/').data, 'GET') self.assert_equal(c.get('/').data, b'GET')
self.assert_equal(c.post('/').data, 'POST') self.assert_equal(c.post('/').data, b'POST')
self.assert_equal(c.put('/').status_code, 405) self.assert_equal(c.put('/').status_code, 405)
meths = parse_set_header(c.open('/', method='OPTIONS').headers['Allow']) meths = parse_set_header(c.open('/', method='OPTIONS').headers['Allow'])
self.assert_equal(sorted(meths), ['GET', 'HEAD', 'OPTIONS', 'POST']) self.assert_equal(sorted(meths), ['GET', 'HEAD', 'OPTIONS', 'POST'])
@ -108,7 +108,7 @@ class ViewTestCase(FlaskTestCase):
c = app.test_client() c = app.test_client()
rv = c.get('/') rv = c.get('/')
self.assert_equal(rv.headers['X-Parachute'], 'awesome') self.assert_equal(rv.headers['X-Parachute'], 'awesome')
self.assert_equal(rv.data, 'Awesome') self.assert_equal(rv.data, b'Awesome')
def test_implicit_head(self): def test_implicit_head(self):
app = flask.Flask(__name__) app = flask.Flask(__name__)
@ -122,10 +122,10 @@ class ViewTestCase(FlaskTestCase):
app.add_url_rule('/', view_func=Index.as_view('index')) app.add_url_rule('/', view_func=Index.as_view('index'))
c = app.test_client() c = app.test_client()
rv = c.get('/') rv = c.get('/')
self.assert_equal(rv.data, 'Blub') self.assert_equal(rv.data, b'Blub')
self.assert_equal(rv.headers['X-Method'], 'GET') self.assert_equal(rv.headers['X-Method'], 'GET')
rv = c.head('/') rv = c.head('/')
self.assert_equal(rv.data, '') self.assert_equal(rv.data, b'')
self.assert_equal(rv.headers['X-Method'], 'HEAD') self.assert_equal(rv.headers['X-Method'], 'HEAD')
def test_explicit_head(self): def test_explicit_head(self):
@ -140,9 +140,9 @@ class ViewTestCase(FlaskTestCase):
app.add_url_rule('/', view_func=Index.as_view('index')) app.add_url_rule('/', view_func=Index.as_view('index'))
c = app.test_client() c = app.test_client()
rv = c.get('/') rv = c.get('/')
self.assert_equal(rv.data, 'GET') self.assert_equal(rv.data, b'GET')
rv = c.head('/') rv = c.head('/')
self.assert_equal(rv.data, '') self.assert_equal(rv.data, b'')
self.assert_equal(rv.headers['X-Method'], 'HEAD') self.assert_equal(rv.headers['X-Method'], 'HEAD')
def test_endpoint_override(self): def test_endpoint_override(self):

Loading…
Cancel
Save