Merge branch '2.1.x'
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by David Lord · committed by David Lord · parents 918fc07, 50374e3 · Browse files · 5 files·+26 added−23 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+26 added−23 removed
- tests:+25 added−22 removed
- other:+1 added−1 removed
Provenance
- Commit
f976d5b- Tree
96cbda9- Author
David Lord <davidism@gmail.com>- Committer
David Lord <davidism@gmail.com>- Parent 1
918fc07- Parent 2
50374e3
5 files changed+26 added−23 removed
modified:tests/test_appctx.py+1 added-1 removed
118 unmodified lines119 @app.route("/")120 def index():121 raise Exception("dummy")122 123- with pytest.raises(Exception):123+ with pytest.raises(Exception, match="dummy"):124 with app.app_context():125 client.get("/")126 127 assert len(cleanup_stuff) == 183 unmodified linesmodified:tests/test_basic.py+17 added-16 removed
148 unmodified lines149 150 151 def test_disallow_string_for_allowed_methods(app):152 with pytest.raises(TypeError):153+ app.add_url_rule("/", methods="GET POST", endpoint="test")154 154- @app.route("/", methods="GET POST")155- def index():156- return "Hey"155 158-156 def test_url_mapping(app, client):157 random_uuid4 = "7eb41166-9ebf-4d26-b771-ea3f54f8b383"158 159 def index():773 unmodified lines933 @app.route("/")934 def broken_func():935 raise KeyboardInterrupt()936 937+ with client:940- with pytest.raises(KeyboardInterrupt):941- client.get("/")938+ with pytest.raises(KeyboardInterrupt):939+ client.get("/")940 941 ctx = flask._request_ctx_stack.top942 assert ctx.preserved943 assert type(ctx._preserved_exc) is KeyboardInterrupt296 unmodified lines1240 c = app.test_client()1241 1242 with pytest.raises(TypeError) as e:1243 c.get("/none")1246- assert "returned None" in str(e.value)1247- assert "from_none" in str(e.value)1244 1245+ assert "returned None" in str(e.value)1246+ assert "from_none" in str(e.value)1247+1248 with pytest.raises(TypeError) as e:1249 c.get("/small_tuple")1251- assert "tuple must have the form" in str(e.value)1250 1253- pytest.raises(TypeError, c.get, "/large_tuple")1251+ assert "tuple must have the form" in str(e.value)1252 1253+ with pytest.raises(TypeError):1254+ c.get("/large_tuple")1255+1256 with pytest.raises(TypeError) as e:1257 c.get("/bad_type")1257- assert "it was a bool" in str(e.value)1258 1259- pytest.raises(TypeError, c.get, "/bad_wsgi")1259+ assert "it was a bool" in str(e.value)1260 1261+ with pytest.raises(TypeError):1262+ c.get("/bad_wsgi")1263 1264+1265 def test_make_response(app, req_ctx):1266 rv = flask.make_response()1267 assert rv.status_code == 2001268 assert rv.data == b""407 unmodified lines1676 return "Awesome"1677 1678 assert not app.got_first_request1679 assert client.get("/").data == b"Awesome"1680+1681 with pytest.raises(AssertionError) as e:1682+ app.add_url_rule("/foo", endpoint="late")1683 1679- @app.route("/foo")1680- def broken():1681- return "Meh"1682-1684 assert "A setup function was called" in str(e.value)1685 1686 app.debug = False1687 349 unmodified linesmodified:tests/test_cli.py+3 added-3 removed
303 unmodified lines304 raise BadExc305 306 lazy = DispatchingApp(bad_load, use_eager_loading=False)307 308- with pytest.raises(BadExc):309- # reduce flakiness by waiting for the internal loading lock310- with lazy._lock:308+ # reduce flakiness by waiting for the internal loading lock309+ with lazy._lock:310+ with pytest.raises(BadExc):311 lazy._flush_bg_loading_exception()312 313 314 def test_with_appcontext(runner):345 unmodified linesmodified:tests/test_config.py+4 added-2 removed
131 unmodified lines132 133 def test_config_from_envvar(monkeypatch):134 monkeypatch.setattr("os.environ", {})135 app = flask.Flask(__name__)136+137 with pytest.raises(RuntimeError) as e:138 app.config.from_envvar("FOO_SETTINGS")139+138- assert "'FOO_SETTINGS' is not set" in str(e.value)140+ assert "'FOO_SETTINGS' is not set" in str(e.value)141 assert not app.config.from_envvar("FOO_SETTINGS", silent=True)142 143 monkeypatch.setattr(144 "os.environ", {"FOO_SETTINGS": f"{__file__.rsplit('.', 1)[0]}.py"}3 unmodified lines148 149 150 def test_config_from_envvar_missing(monkeypatch):151 monkeypatch.setattr("os.environ", {"FOO_SETTINGS": "missing.cfg"})152+ app = flask.Flask(__name__)153 with pytest.raises(IOError) as e:151- app = flask.Flask(__name__)154 app.config.from_envvar("FOO_SETTINGS")155 msg = str(e.value)156 assert msg.startswith(157 "[Errno 2] Unable to load configuration file (No such file or directory):"97 unmodified linesmodified:CHANGES.rst+1 added-1 removed
7 unmodified lines8 9 Version 2.1.210 -------------11 12-Unreleased12+Released 2022-04-2813 14 - Fix type annotation for ``json.loads``, it accepts str or bytes.15 :issue:`4519`16 - The ``--cert`` and ``--key`` options on ``flask run`` can be given1274 unmodified lines