Skip to content
Myr

Added tests for make_response and get_debug_flag to improve coverage of helpers.py

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by MikeTheReader · committed by MikeTheReader · parent a0e38a8 · Browse files · 1 file+50 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+50 added−0 removed

  • tests:+50 added−0 removed

1 file+50 added−0 removed

modified:tests/test_helpers.py+50 added
20 unmodified lines
21from werkzeug.exceptions import BadRequest, NotFound22from werkzeug.http import parse_cache_control_header, parse_options_header23from werkzeug.http import http_date24from flask._compat import StringIO, text_type25from flask.helpers import get_debug_flag, make_response262728def has_encoding(name):29 try:
911 unmodified lines
941942 for args in failing:943 with pytest.raises(NotFound):944 print(flask.safe_join(*args))945946class TestHelpers(object):947948 def test_get_debug_flag(self):949 original_debug_value = os.environ.get('FLASK_DEBUG') or ''950 os.environ['FLASK_DEBUG'] = ''951 assert get_debug_flag() == None952 assert get_debug_flag(default=True) == True953954 os.environ['FLASK_DEBUG'] = '0'955 assert get_debug_flag() == False956 assert get_debug_flag(default=True) == False957958 os.environ['FLASK_DEBUG'] = 'False'959 assert get_debug_flag() == False960 assert get_debug_flag(default=True) == False961962 os.environ['FLASK_DEBUG'] = 'No'963 assert get_debug_flag() == False964 assert get_debug_flag(default=True) == False965966 os.environ['FLASK_DEBUG'] = 'True'967 assert get_debug_flag() == True968 assert get_debug_flag(default=True) == True969970 os.environ['FLASK_DEBUG'] = original_debug_value971972 def test_make_response_no_args(self):973 app = flask.Flask(__name__)974 app.testing = True975 @app.route('/')976 def index():977 return flask.helpers.make_response()978 c = app.test_client()979 rv = c.get()980 assert rv981982 def test_make_response_with_args(self):983 app = flask.Flask(__name__)984 app.testing = True985 @app.route('/')986 def index():987 response = flask.helpers.make_response(flask.render_template_string('Hello World'))988 response.headers['X-Parachutes'] = 'parachutes are cool'989 return response990 c = app.test_client()991 rv = c.get()992 assert rv993 assert rv.headers['X-Parachutes'] == 'parachutes are cool'