Skip to content
Myr

Merge pull request #2303 from MikeTheReader/master

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

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

authored by David Lord · committed by GitHub · parents 11d2eec, 7c882a4 · Browse files · 1 file+30 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+30 added−0 removed

  • tests:+30 added−0 removed

1 file+30 added−0 removed

modified:tests/test_helpers.py+30 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 @pytest.mark.parametrize('debug, expected_flag, expected_default_flag', [949 ('', None, True),950 ('0', False, False),951 ('False', False, False),952 ('No', False, False),953 ('True', True, True)954 ])955 def test_get_debug_flag(self, monkeypatch, debug, expected_flag, expected_default_flag):956 monkeypatch.setenv('FLASK_DEBUG', debug)957 if expected_flag is None:958 assert get_debug_flag() is None959 else:960 assert get_debug_flag() == expected_flag961 assert get_debug_flag(default=True) == expected_default_flag962963 def test_make_response(self):964 app = flask.Flask(__name__)965 with app.test_request_context():966 rv = flask.helpers.make_response()967 assert rv.status_code == 200968 assert rv.mimetype == 'text/html'969970 rv = flask.helpers.make_response('Hello')971 assert rv.status_code == 200972 assert rv.data == b'Hello'973 assert rv.mimetype == 'text/html'