diff --git a/flask/testsuite/__init__.py b/flask/testsuite/__init__.py index 9088fc52..72de1963 100644 --- a/flask/testsuite/__init__.py +++ b/flask/testsuite/__init__.py @@ -103,7 +103,7 @@ def emits_module_deprecation_warning(f): f(self, *args, **kwargs) self.assert_true(log, 'expected deprecation warning') for entry in log: - self.assert_true('Modules are deprecated' in str(entry['message'])) + self.assert_in('Modules are deprecated', str(entry['message'])) return update_wrapper(new_f, f) @@ -145,6 +145,12 @@ class FlaskTestCase(unittest.TestCase): def assert_true(self, x, msg=None): self.assertTrue(x, msg) + def assert_in(self, x, y): + self.assertIn(x, y) + + def assert_not_in(self, x, y): + self.assertNotIn(x, y) + class _ExceptionCatcher(object): diff --git a/flask/testsuite/basic.py b/flask/testsuite/basic.py index 20c2f0cc..0abcac10 100644 --- a/flask/testsuite/basic.py +++ b/flask/testsuite/basic.py @@ -173,8 +173,8 @@ class BasicFunctionalityTestCase(FlaskTestCase): flask.session['testing'] = 42 return 'Hello World' rv = app.test_client().get('/', 'http://example.com/') - self.assert_true('domain=.example.com' in rv.headers['set-cookie'].lower()) - self.assert_true('httponly' in rv.headers['set-cookie'].lower()) + self.assert_in('domain=.example.com', rv.headers['set-cookie'].lower()) + self.assert_in('httponly', rv.headers['set-cookie'].lower()) def test_session_using_server_name_and_port(self): app = flask.Flask(__name__) @@ -187,8 +187,8 @@ class BasicFunctionalityTestCase(FlaskTestCase): flask.session['testing'] = 42 return 'Hello World' rv = app.test_client().get('/', 'http://example.com:8080/') - self.assert_true('domain=.example.com' in rv.headers['set-cookie'].lower()) - self.assert_true('httponly' in rv.headers['set-cookie'].lower()) + self.assert_in('domain=.example.com', rv.headers['set-cookie'].lower()) + self.assert_in('httponly', rv.headers['set-cookie'].lower()) def test_session_using_server_name_port_and_path(self): app = flask.Flask(__name__) @@ -202,9 +202,9 @@ class BasicFunctionalityTestCase(FlaskTestCase): flask.session['testing'] = 42 return 'Hello World' rv = app.test_client().get('/', 'http://example.com:8080/foo') - self.assert_true('domain=example.com' in rv.headers['set-cookie'].lower()) - self.assert_true('path=/foo' in rv.headers['set-cookie'].lower()) - self.assert_true('httponly' in rv.headers['set-cookie'].lower()) + self.assert_in('domain=example.com', rv.headers['set-cookie'].lower()) + self.assert_in('path=/foo', rv.headers['set-cookie'].lower()) + self.assert_in('httponly', rv.headers['set-cookie'].lower()) def test_session_using_application_root(self): class PrefixPathMiddleware(object): @@ -226,7 +226,7 @@ class BasicFunctionalityTestCase(FlaskTestCase): flask.session['testing'] = 42 return 'Hello World' rv = app.test_client().get('/', 'http://example.com:8080/') - self.assert_true('path=/bar' in rv.headers['set-cookie'].lower()) + self.assert_in('path=/bar', rv.headers['set-cookie'].lower()) def test_session_using_session_settings(self): app = flask.Flask(__name__) @@ -245,10 +245,10 @@ class BasicFunctionalityTestCase(FlaskTestCase): return 'Hello World' rv = app.test_client().get('/', 'http://www.example.com:8080/test/') cookie = rv.headers['set-cookie'].lower() - self.assert_true('domain=.example.com' in cookie) - self.assert_true('path=/;' in cookie) - self.assert_true('secure' in cookie) - self.assert_true('httponly' not in cookie) + self.assert_in('domain=.example.com', cookie) + self.assert_in('path=/;', cookie) + self.assert_in('secure', cookie) + self.assert_not_in('httponly', cookie) def test_missing_session(self): app = flask.Flask(__name__) @@ -280,7 +280,7 @@ class BasicFunctionalityTestCase(FlaskTestCase): client = app.test_client() rv = client.get('/') - self.assert_true('set-cookie' in rv.headers) + self.assert_in('set-cookie', rv.headers) match = re.search(r'\bexpires=([^;]+)', rv.headers['set-cookie']) expires = parse_date(match.group()) expected = datetime.utcnow() + app.permanent_session_lifetime @@ -293,7 +293,7 @@ class BasicFunctionalityTestCase(FlaskTestCase): permanent = False rv = app.test_client().get('/') - self.assert_true('set-cookie' in rv.headers) + self.assert_in('set-cookie', rv.headers) match = re.search(r'\bexpires=([^;]+)', rv.headers['set-cookie']) self.assert_true(match is None) @@ -448,12 +448,12 @@ class BasicFunctionalityTestCase(FlaskTestCase): return response @app.route('/') def index(): - self.assert_true('before' in evts) - self.assert_true('after' not in evts) + self.assert_in('before', evts) + self.assert_not_in('after', evts) return 'request' - self.assert_true('after' not in evts) + self.assert_not_in('after', evts) rv = app.test_client().get('/').data - self.assert_true(b'after' in evts) + self.assert_in(b'after', evts) self.assert_equal(rv, b'request|after') def test_after_request_processing(self): @@ -483,7 +483,7 @@ class BasicFunctionalityTestCase(FlaskTestCase): return "Response" rv = app.test_client().get('/') self.assert_equal(rv.status_code, 200) - self.assert_true(b'Response' in rv.data) + self.assert_in(b'Response', rv.data) self.assert_equal(len(called), 1) def test_teardown_request_handler_debug_mode(self): @@ -499,7 +499,7 @@ class BasicFunctionalityTestCase(FlaskTestCase): return "Response" rv = app.test_client().get('/') self.assert_equal(rv.status_code, 200) - self.assert_true(b'Response' in rv.data) + self.assert_in(b'Response', rv.data) self.assert_equal(len(called), 1) def test_teardown_request_handler_error(self): @@ -532,7 +532,7 @@ class BasicFunctionalityTestCase(FlaskTestCase): 1/0 rv = app.test_client().get('/') self.assert_equal(rv.status_code, 500) - self.assert_true(b'Internal Server Error' in rv.data) + self.assert_in(b'Internal Server Error', rv.data) self.assert_equal(len(called), 2) def test_before_after_request_order(self): @@ -664,8 +664,8 @@ class BasicFunctionalityTestCase(FlaskTestCase): try: c.post('/fail', data={'foo': 'index.txt'}) except DebugFilesKeyError as e: - self.assert_true('no file contents were transmitted' in str(e)) - self.assert_true('This was submitted: "index.txt"' in str(e)) + self.assert_in('no file contents were transmitted', str(e)) + self.assert_in('This was submitted: "index.txt"', str(e)) else: self.fail('Expected exception') @@ -974,7 +974,7 @@ class BasicFunctionalityTestCase(FlaskTestCase): def broken(): return 'Meh' except AssertionError as e: - self.assert_true('A setup function was called' in str(e)) + self.assert_in('A setup function was called', str(e)) else: self.fail('Expected exception') @@ -1008,9 +1008,9 @@ class BasicFunctionalityTestCase(FlaskTestCase): try: c.post('/foo', data={}) except AssertionError as e: - self.assert_true('http://localhost/foo/' in str(e)) - self.assert_true('Make sure to directly send your POST-request ' - 'to this URL' in str(e)) + self.assert_in('http://localhost/foo/', str(e)) + self.assert_in('Make sure to directly send your POST-request ' + 'to this URL', str(e)) else: self.fail('Expected exception') diff --git a/flask/testsuite/blueprints.py b/flask/testsuite/blueprints.py index 088c72d2..89a8f2d7 100644 --- a/flask/testsuite/blueprints.py +++ b/flask/testsuite/blueprints.py @@ -547,7 +547,7 @@ class BlueprintTestCase(FlaskTestCase): return s[::-1] app = flask.Flask(__name__) app.register_blueprint(bp, url_prefix='/py') - self.assert_true('my_reverse' in app.jinja_env.filters.keys()) + self.assert_in('my_reverse', app.jinja_env.filters.keys()) self.assert_equal(app.jinja_env.filters['my_reverse'], my_reverse) self.assert_equal(app.jinja_env.filters['my_reverse']('abcd'), 'dcba') @@ -558,7 +558,7 @@ class BlueprintTestCase(FlaskTestCase): bp.add_app_template_filter(my_reverse) app = flask.Flask(__name__) app.register_blueprint(bp, url_prefix='/py') - self.assert_true('my_reverse' in app.jinja_env.filters.keys()) + self.assert_in('my_reverse', app.jinja_env.filters.keys()) self.assert_equal(app.jinja_env.filters['my_reverse'], my_reverse) self.assert_equal(app.jinja_env.filters['my_reverse']('abcd'), 'dcba') @@ -569,7 +569,7 @@ class BlueprintTestCase(FlaskTestCase): return s[::-1] app = flask.Flask(__name__) app.register_blueprint(bp, url_prefix='/py') - self.assert_true('strrev' in app.jinja_env.filters.keys()) + self.assert_in('strrev', app.jinja_env.filters.keys()) self.assert_equal(app.jinja_env.filters['strrev'], my_reverse) self.assert_equal(app.jinja_env.filters['strrev']('abcd'), 'dcba') @@ -580,7 +580,7 @@ class BlueprintTestCase(FlaskTestCase): bp.add_app_template_filter(my_reverse, 'strrev') app = flask.Flask(__name__) app.register_blueprint(bp, url_prefix='/py') - self.assert_true('strrev' in app.jinja_env.filters.keys()) + self.assert_in('strrev', app.jinja_env.filters.keys()) self.assert_equal(app.jinja_env.filters['strrev'], my_reverse) self.assert_equal(app.jinja_env.filters['strrev']('abcd'), 'dcba') @@ -656,7 +656,7 @@ class BlueprintTestCase(FlaskTestCase): return isinstance(value, bool) app = flask.Flask(__name__) app.register_blueprint(bp, url_prefix='/py') - self.assert_true('is_boolean' in app.jinja_env.tests.keys()) + self.assert_in('is_boolean', app.jinja_env.tests.keys()) self.assert_equal(app.jinja_env.tests['is_boolean'], is_boolean) self.assert_true(app.jinja_env.tests['is_boolean'](False)) @@ -667,7 +667,7 @@ class BlueprintTestCase(FlaskTestCase): bp.add_app_template_test(is_boolean) app = flask.Flask(__name__) app.register_blueprint(bp, url_prefix='/py') - self.assert_true('is_boolean' in app.jinja_env.tests.keys()) + self.assert_in('is_boolean', app.jinja_env.tests.keys()) self.assert_equal(app.jinja_env.tests['is_boolean'], is_boolean) self.assert_true(app.jinja_env.tests['is_boolean'](False)) @@ -678,7 +678,7 @@ class BlueprintTestCase(FlaskTestCase): return isinstance(value, bool) app = flask.Flask(__name__) app.register_blueprint(bp, url_prefix='/py') - self.assert_true('boolean' in app.jinja_env.tests.keys()) + self.assert_in('boolean', app.jinja_env.tests.keys()) self.assert_equal(app.jinja_env.tests['boolean'], is_boolean) self.assert_true(app.jinja_env.tests['boolean'](False)) @@ -689,7 +689,7 @@ class BlueprintTestCase(FlaskTestCase): bp.add_app_template_test(is_boolean, 'boolean') app = flask.Flask(__name__) app.register_blueprint(bp, url_prefix='/py') - self.assert_true('boolean' in app.jinja_env.tests.keys()) + self.assert_in('boolean', app.jinja_env.tests.keys()) self.assert_equal(app.jinja_env.tests['boolean'], is_boolean) self.assert_true(app.jinja_env.tests['boolean'](False)) @@ -704,7 +704,7 @@ class BlueprintTestCase(FlaskTestCase): def index(): return flask.render_template('template_test.html', value=False) rv = app.test_client().get('/') - self.assert_true(b'Success!' in rv.data) + self.assert_in(b'Success!', rv.data) def test_template_test_after_route_with_template(self): app = flask.Flask(__name__) @@ -717,7 +717,7 @@ class BlueprintTestCase(FlaskTestCase): return isinstance(value, bool) app.register_blueprint(bp, url_prefix='/py') rv = app.test_client().get('/') - self.assert_true(b'Success!' in rv.data) + self.assert_in(b'Success!', rv.data) def test_add_template_test_with_template(self): bp = flask.Blueprint('bp', __name__) @@ -730,7 +730,7 @@ class BlueprintTestCase(FlaskTestCase): def index(): return flask.render_template('template_test.html', value=False) rv = app.test_client().get('/') - self.assert_true(b'Success!' in rv.data) + self.assert_in(b'Success!', rv.data) def test_template_test_with_name_and_template(self): bp = flask.Blueprint('bp', __name__) @@ -743,7 +743,7 @@ class BlueprintTestCase(FlaskTestCase): def index(): return flask.render_template('template_test.html', value=False) rv = app.test_client().get('/') - self.assert_true(b'Success!' in rv.data) + self.assert_in(b'Success!', rv.data) def test_add_template_test_with_name_and_template(self): bp = flask.Blueprint('bp', __name__) @@ -756,7 +756,7 @@ class BlueprintTestCase(FlaskTestCase): def index(): return flask.render_template('template_test.html', value=False) rv = app.test_client().get('/') - self.assert_true(b'Success!' in rv.data) + self.assert_in(b'Success!', rv.data) def suite(): suite = unittest.TestSuite() diff --git a/flask/testsuite/config.py b/flask/testsuite/config.py index 6633c6ba..8aaf5285 100644 --- a/flask/testsuite/config.py +++ b/flask/testsuite/config.py @@ -28,7 +28,7 @@ class ConfigTestCase(FlaskTestCase): def common_object_test(self, app): self.assert_equal(app.secret_key, 'devkey') self.assert_equal(app.config['TEST_KEY'], 'foo') - self.assert_true('ConfigTestCase' not in app.config) + self.assert_not_in('ConfigTestCase', app.config) def test_config_from_file(self): app = flask.Flask(__name__) @@ -141,7 +141,7 @@ class InstanceTestCase(FlaskTestCase): try: flask.Flask(__name__, instance_path='instance') except ValueError as e: - self.assert_true('must be absolute' in str(e)) + self.assert_in('must be absolute', str(e)) else: self.fail('Expected value error') diff --git a/flask/testsuite/ext.py b/flask/testsuite/ext.py index a6d1be9d..04226181 100644 --- a/flask/testsuite/ext.py +++ b/flask/testsuite/ext.py @@ -42,7 +42,7 @@ class ExtImportHookTestCase(FlaskTestCase): def teardown(self): from flask import ext for key in ext.__dict__: - self.assert_true('.' not in key) + self.assert_not_in('.', key) def test_flaskext_new_simple_import_normal(self): from flask.ext.newext_simple import ext_id @@ -113,7 +113,7 @@ class ExtImportHookTestCase(FlaskTestCase): self.assert_true(tb.tb_frame.f_globals is globals()) next = tb.tb_next - self.assert_true('flask_broken/__init__.py' in next.tb_frame.f_code.co_filename) + self.assert_in('flask_broken/__init__.py', next.tb_frame.f_code.co_filename) def suite(): diff --git a/flask/testsuite/helpers.py b/flask/testsuite/helpers.py index 702ab517..b76d36d1 100644 --- a/flask/testsuite/helpers.py +++ b/flask/testsuite/helpers.py @@ -48,8 +48,8 @@ class JSONTestCase(FlaskTestCase): rv = c.post('/json', data='malformed', content_type='application/json') self.assert_equal(rv.status_code, 400) self.assert_equal(rv.mimetype, 'application/json') - self.assert_true('description' in flask.json.loads(rv.data)) - self.assert_true('
' not in flask.json.loads(rv.data)['description']) + self.assert_in('description', flask.json.loads(rv.data)) + self.assert_not_in('
', flask.json.loads(rv.data)['description']) def test_json_body_encoding(self): app = flask.Flask(__name__) @@ -178,7 +178,7 @@ class SendfileTestCase(FlaskTestCase): with app.test_request_context(): rv = flask.send_file('static/index.html') self.assert_true(rv.direct_passthrough) - self.assert_true('x-sendfile' in rv.headers) + self.assert_in('x-sendfile', rv.headers) self.assert_equal(rv.headers['x-sendfile'], os.path.join(app.root_path, 'static/index.html')) self.assert_equal(rv.mimetype, 'text/html') @@ -201,7 +201,7 @@ class SendfileTestCase(FlaskTestCase): f = open(os.path.join(app.root_path, 'static/index.html')) rv = flask.send_file(f) self.assert_equal(rv.mimetype, 'text/html') - self.assert_true('x-sendfile' in rv.headers) + self.assert_in('x-sendfile', rv.headers) self.assert_equal(rv.headers['x-sendfile'], os.path.join(app.root_path, 'static/index.html')) # mimetypes + etag @@ -229,7 +229,7 @@ class SendfileTestCase(FlaskTestCase): with app.test_request_context(): f = StringIO('Test') rv = flask.send_file(f) - self.assert_true('x-sendfile' not in rv.headers) + self.assert_not_in('x-sendfile', rv.headers) # etags self.assert_equal(len(captured), 1) @@ -325,10 +325,10 @@ class LoggingTestCase(FlaskTestCase): with catch_stderr() as err: c.get('/') out = err.getvalue() - self.assert_true('WARNING in helpers [' in out) - self.assert_true(os.path.basename(__file__.rsplit('.', 1)[0] + '.py') in out) - self.assert_true('the standard library is dead' in out) - self.assert_true('this is a debug statement' in out) + self.assert_in('WARNING in helpers [', out) + self.assert_in(os.path.basename(__file__.rsplit('.', 1)[0] + '.py'), out) + self.assert_in('the standard library is dead', out) + self.assert_in('this is a debug statement', out) with catch_stderr() as err: try: @@ -357,13 +357,13 @@ class LoggingTestCase(FlaskTestCase): rv = app.test_client().get('/') self.assert_equal(rv.status_code, 500) - self.assert_true(b'Internal Server Error' in rv.data) + self.assert_in(b'Internal Server Error', rv.data) err = out.getvalue() - self.assert_true('Exception on / [GET]' in err) - self.assert_true('Traceback (most recent call last):' in err) - self.assert_true('1/0' in err) - self.assert_true('ZeroDivisionError:' in err) + self.assert_in('Exception on / [GET]', err) + self.assert_in('Traceback (most recent call last):', err) + self.assert_in('1/0', err) + self.assert_in('ZeroDivisionError:', err) def test_processor_exceptions(self): app = flask.Flask(__name__) diff --git a/flask/testsuite/subclassing.py b/flask/testsuite/subclassing.py index a3cf5d0e..dbfdd499 100644 --- a/flask/testsuite/subclassing.py +++ b/flask/testsuite/subclassing.py @@ -34,7 +34,7 @@ class FlaskSubclassingTestCase(FlaskTestCase): rv = app.test_client().get('/') self.assert_equal(rv.status_code, 500) - self.assert_true(b'Internal Server Error' in rv.data) + self.assert_in(b'Internal Server Error', rv.data) err = out.getvalue() self.assert_equal(err, '') diff --git a/flask/testsuite/templating.py b/flask/testsuite/templating.py index 08a54d06..b2870dea 100644 --- a/flask/testsuite/templating.py +++ b/flask/testsuite/templating.py @@ -99,7 +99,7 @@ class TemplatingTestCase(FlaskTestCase): @app.template_filter() def my_reverse(s): return s[::-1] - self.assert_true('my_reverse' in app.jinja_env.filters.keys()) + self.assert_in('my_reverse', app.jinja_env.filters.keys()) self.assert_equal(app.jinja_env.filters['my_reverse'], my_reverse) self.assert_equal(app.jinja_env.filters['my_reverse']('abcd'), 'dcba') @@ -108,7 +108,7 @@ class TemplatingTestCase(FlaskTestCase): def my_reverse(s): return s[::-1] app.add_template_filter(my_reverse) - self.assert_true('my_reverse' in app.jinja_env.filters.keys()) + self.assert_in('my_reverse', app.jinja_env.filters.keys()) self.assert_equal(app.jinja_env.filters['my_reverse'], my_reverse) self.assert_equal(app.jinja_env.filters['my_reverse']('abcd'), 'dcba') @@ -117,7 +117,7 @@ class TemplatingTestCase(FlaskTestCase): @app.template_filter('strrev') def my_reverse(s): return s[::-1] - self.assert_true('strrev' in app.jinja_env.filters.keys()) + self.assert_in('strrev', app.jinja_env.filters.keys()) self.assert_equal(app.jinja_env.filters['strrev'], my_reverse) self.assert_equal(app.jinja_env.filters['strrev']('abcd'), 'dcba') @@ -126,7 +126,7 @@ class TemplatingTestCase(FlaskTestCase): def my_reverse(s): return s[::-1] app.add_template_filter(my_reverse, 'strrev') - self.assert_true('strrev' in app.jinja_env.filters.keys()) + self.assert_in('strrev', app.jinja_env.filters.keys()) self.assert_equal(app.jinja_env.filters['strrev'], my_reverse) self.assert_equal(app.jinja_env.filters['strrev']('abcd'), 'dcba') @@ -179,7 +179,7 @@ class TemplatingTestCase(FlaskTestCase): @app.template_test() def boolean(value): return isinstance(value, bool) - self.assert_true('boolean' in app.jinja_env.tests.keys()) + self.assert_in('boolean', app.jinja_env.tests.keys()) self.assert_equal(app.jinja_env.tests['boolean'], boolean) self.assert_true(app.jinja_env.tests['boolean'](False)) @@ -188,7 +188,7 @@ class TemplatingTestCase(FlaskTestCase): def boolean(value): return isinstance(value, bool) app.add_template_test(boolean) - self.assert_true('boolean' in app.jinja_env.tests.keys()) + self.assert_in('boolean', app.jinja_env.tests.keys()) self.assert_equal(app.jinja_env.tests['boolean'], boolean) self.assert_true(app.jinja_env.tests['boolean'](False)) @@ -197,7 +197,7 @@ class TemplatingTestCase(FlaskTestCase): @app.template_test('boolean') def is_boolean(value): return isinstance(value, bool) - self.assert_true('boolean' in app.jinja_env.tests.keys()) + self.assert_in('boolean', app.jinja_env.tests.keys()) self.assert_equal(app.jinja_env.tests['boolean'], is_boolean) self.assert_true(app.jinja_env.tests['boolean'](False)) @@ -206,7 +206,7 @@ class TemplatingTestCase(FlaskTestCase): def is_boolean(value): return isinstance(value, bool) app.add_template_test(is_boolean, 'boolean') - self.assert_true('boolean' in app.jinja_env.tests.keys()) + self.assert_in('boolean', app.jinja_env.tests.keys()) self.assert_equal(app.jinja_env.tests['boolean'], is_boolean) self.assert_true(app.jinja_env.tests['boolean'](False)) @@ -219,7 +219,7 @@ class TemplatingTestCase(FlaskTestCase): def index(): return flask.render_template('template_test.html', value=False) rv = app.test_client().get('/') - self.assert_true(b'Success!' in rv.data) + self.assert_in(b'Success!', rv.data) def test_add_template_test_with_template(self): app = flask.Flask(__name__) @@ -230,7 +230,7 @@ class TemplatingTestCase(FlaskTestCase): def index(): return flask.render_template('template_test.html', value=False) rv = app.test_client().get('/') - self.assert_true(b'Success!' in rv.data) + self.assert_in(b'Success!', rv.data) def test_template_test_with_name_and_template(self): app = flask.Flask(__name__) @@ -241,7 +241,7 @@ class TemplatingTestCase(FlaskTestCase): def index(): return flask.render_template('template_test.html', value=False) rv = app.test_client().get('/') - self.assert_true(b'Success!' in rv.data) + self.assert_in(b'Success!', rv.data) def test_add_template_test_with_name_and_template(self): app = flask.Flask(__name__) @@ -252,14 +252,14 @@ class TemplatingTestCase(FlaskTestCase): def index(): return flask.render_template('template_test.html', value=False) rv = app.test_client().get('/') - self.assert_true(b'Success!' in rv.data) + self.assert_in(b'Success!', rv.data) def test_add_template_global(self): app = flask.Flask(__name__) @app.template_global() def get_stuff(): return 42 - self.assert_true('get_stuff' in app.jinja_env.globals.keys()) + self.assert_in('get_stuff', app.jinja_env.globals.keys()) self.assert_equal(app.jinja_env.globals['get_stuff'], get_stuff) self.assert_true(app.jinja_env.globals['get_stuff'](), 42) with app.app_context(): diff --git a/flask/testsuite/testing.py b/flask/testsuite/testing.py index 2e735c47..a60109e1 100644 --- a/flask/testsuite/testing.py +++ b/flask/testsuite/testing.py @@ -106,7 +106,7 @@ class TestToolsTestCase(FlaskTestCase): with c.session_transaction() as sess: pass except RuntimeError as e: - self.assert_true('Session backend did not open a session' in str(e)) + self.assert_in('Session backend did not open a session', str(e)) else: self.fail('Expected runtime error') @@ -130,7 +130,7 @@ class TestToolsTestCase(FlaskTestCase): with c.session_transaction() as s: pass except RuntimeError as e: - self.assert_true('cookies' in str(e)) + self.assert_in('cookies', str(e)) else: self.fail('Expected runtime error') @@ -153,7 +153,7 @@ class TestToolsTestCase(FlaskTestCase): resp = c.get('/other') self.assert_true(not hasattr(flask.g, 'value')) - self.assert_true(b'Internal Server Error' in resp.data) + self.assert_in(b'Internal Server Error', resp.data) self.assert_equal(resp.status_code, 500) flask.g.value = 23