forked from orbit-oss/flask
Merge branch '2.1.x'
This commit is contained in:
commit
f976d5bb88
5 changed files with 26 additions and 23 deletions
|
|
@ -9,7 +9,7 @@ Unreleased
|
||||||
Version 2.1.2
|
Version 2.1.2
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
Unreleased
|
Released 2022-04-28
|
||||||
|
|
||||||
- Fix type annotation for ``json.loads``, it accepts str or bytes.
|
- Fix type annotation for ``json.loads``, it accepts str or bytes.
|
||||||
:issue:`4519`
|
:issue:`4519`
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ def test_app_tearing_down_with_unhandled_exception(app, client):
|
||||||
def index():
|
def index():
|
||||||
raise Exception("dummy")
|
raise Exception("dummy")
|
||||||
|
|
||||||
with pytest.raises(Exception):
|
with pytest.raises(Exception, match="dummy"):
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
client.get("/")
|
client.get("/")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -150,10 +150,7 @@ def test_request_dispatching(app, client):
|
||||||
|
|
||||||
def test_disallow_string_for_allowed_methods(app):
|
def test_disallow_string_for_allowed_methods(app):
|
||||||
with pytest.raises(TypeError):
|
with pytest.raises(TypeError):
|
||||||
|
app.add_url_rule("/", methods="GET POST", endpoint="test")
|
||||||
@app.route("/", methods="GET POST")
|
|
||||||
def index():
|
|
||||||
return "Hey"
|
|
||||||
|
|
||||||
|
|
||||||
def test_url_mapping(app, client):
|
def test_url_mapping(app, client):
|
||||||
|
|
@ -937,8 +934,9 @@ def test_baseexception_error_handling(app, client):
|
||||||
def broken_func():
|
def broken_func():
|
||||||
raise KeyboardInterrupt()
|
raise KeyboardInterrupt()
|
||||||
|
|
||||||
with pytest.raises(KeyboardInterrupt):
|
with client:
|
||||||
client.get("/")
|
with pytest.raises(KeyboardInterrupt):
|
||||||
|
client.get("/")
|
||||||
|
|
||||||
ctx = flask._request_ctx_stack.top
|
ctx = flask._request_ctx_stack.top
|
||||||
assert ctx.preserved
|
assert ctx.preserved
|
||||||
|
|
@ -1243,20 +1241,25 @@ def test_response_type_errors():
|
||||||
|
|
||||||
with pytest.raises(TypeError) as e:
|
with pytest.raises(TypeError) as e:
|
||||||
c.get("/none")
|
c.get("/none")
|
||||||
assert "returned None" in str(e.value)
|
|
||||||
assert "from_none" in str(e.value)
|
assert "returned None" in str(e.value)
|
||||||
|
assert "from_none" in str(e.value)
|
||||||
|
|
||||||
with pytest.raises(TypeError) as e:
|
with pytest.raises(TypeError) as e:
|
||||||
c.get("/small_tuple")
|
c.get("/small_tuple")
|
||||||
assert "tuple must have the form" in str(e.value)
|
|
||||||
|
|
||||||
pytest.raises(TypeError, c.get, "/large_tuple")
|
assert "tuple must have the form" in str(e.value)
|
||||||
|
|
||||||
|
with pytest.raises(TypeError):
|
||||||
|
c.get("/large_tuple")
|
||||||
|
|
||||||
with pytest.raises(TypeError) as e:
|
with pytest.raises(TypeError) as e:
|
||||||
c.get("/bad_type")
|
c.get("/bad_type")
|
||||||
assert "it was a bool" in str(e.value)
|
|
||||||
|
|
||||||
pytest.raises(TypeError, c.get, "/bad_wsgi")
|
assert "it was a bool" in str(e.value)
|
||||||
|
|
||||||
|
with pytest.raises(TypeError):
|
||||||
|
c.get("/bad_wsgi")
|
||||||
|
|
||||||
|
|
||||||
def test_make_response(app, req_ctx):
|
def test_make_response(app, req_ctx):
|
||||||
|
|
@ -1674,11 +1677,9 @@ def test_debug_mode_complains_after_first_request(app, client):
|
||||||
|
|
||||||
assert not app.got_first_request
|
assert not app.got_first_request
|
||||||
assert client.get("/").data == b"Awesome"
|
assert client.get("/").data == b"Awesome"
|
||||||
with pytest.raises(AssertionError) as e:
|
|
||||||
|
|
||||||
@app.route("/foo")
|
with pytest.raises(AssertionError) as e:
|
||||||
def broken():
|
app.add_url_rule("/foo", endpoint="late")
|
||||||
return "Meh"
|
|
||||||
|
|
||||||
assert "A setup function was called" in str(e.value)
|
assert "A setup function was called" in str(e.value)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -305,9 +305,9 @@ def test_lazy_load_error(monkeypatch):
|
||||||
|
|
||||||
lazy = DispatchingApp(bad_load, use_eager_loading=False)
|
lazy = DispatchingApp(bad_load, use_eager_loading=False)
|
||||||
|
|
||||||
with pytest.raises(BadExc):
|
# reduce flakiness by waiting for the internal loading lock
|
||||||
# reduce flakiness by waiting for the internal loading lock
|
with lazy._lock:
|
||||||
with lazy._lock:
|
with pytest.raises(BadExc):
|
||||||
lazy._flush_bg_loading_exception()
|
lazy._flush_bg_loading_exception()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -133,9 +133,11 @@ def test_config_from_class():
|
||||||
def test_config_from_envvar(monkeypatch):
|
def test_config_from_envvar(monkeypatch):
|
||||||
monkeypatch.setattr("os.environ", {})
|
monkeypatch.setattr("os.environ", {})
|
||||||
app = flask.Flask(__name__)
|
app = flask.Flask(__name__)
|
||||||
|
|
||||||
with pytest.raises(RuntimeError) as e:
|
with pytest.raises(RuntimeError) as e:
|
||||||
app.config.from_envvar("FOO_SETTINGS")
|
app.config.from_envvar("FOO_SETTINGS")
|
||||||
assert "'FOO_SETTINGS' is not set" in str(e.value)
|
|
||||||
|
assert "'FOO_SETTINGS' is not set" in str(e.value)
|
||||||
assert not app.config.from_envvar("FOO_SETTINGS", silent=True)
|
assert not app.config.from_envvar("FOO_SETTINGS", silent=True)
|
||||||
|
|
||||||
monkeypatch.setattr(
|
monkeypatch.setattr(
|
||||||
|
|
@ -147,8 +149,8 @@ def test_config_from_envvar(monkeypatch):
|
||||||
|
|
||||||
def test_config_from_envvar_missing(monkeypatch):
|
def test_config_from_envvar_missing(monkeypatch):
|
||||||
monkeypatch.setattr("os.environ", {"FOO_SETTINGS": "missing.cfg"})
|
monkeypatch.setattr("os.environ", {"FOO_SETTINGS": "missing.cfg"})
|
||||||
|
app = flask.Flask(__name__)
|
||||||
with pytest.raises(IOError) as e:
|
with pytest.raises(IOError) as e:
|
||||||
app = flask.Flask(__name__)
|
|
||||||
app.config.from_envvar("FOO_SETTINGS")
|
app.config.from_envvar("FOO_SETTINGS")
|
||||||
msg = str(e.value)
|
msg = str(e.value)
|
||||||
assert msg.startswith(
|
assert msg.startswith(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue