test_basic.py
This file
Path
tests/test_basic.py
1,944 lines · 52.0 KiB · Python
Last changed by
Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
History of this fileTake it
The walk stopped after 200 commits: lines older than 49f3e96 point at it.
Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 1–7why, one step back1# -*- coding: utf-8 -*-2"""3 tests.basic4 ~~~~~~~~~~~~~~~~~~~~~56 The basic functionality.7Merge pull request #2624 from pallets/metadataDavid Lordbefore adoption4309c7c
line 8why, one step back8 :copyright: © 2010 by the Pallets team.Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 9–28why, one step back9 :license: BSD, see LICENSE for more details.10"""1112import re13import time14import uuid15from datetime import datetime16from threading import Thread1718import pytest19import werkzeug.serving20from werkzeug.exceptions import BadRequest, Forbidden, NotFound21from werkzeug.http import parse_date22from werkzeug.routing import BuildError2324import flask25from flask._compat import text_type262728def test_options_work(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 29–37why, one step back29 @app.route("/", methods=["GET", "POST"])30 def index():31 return "Hello World"3233 rv = client.open("/", method="OPTIONS")34 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS", "POST"]35 assert rv.data == b""3637Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 38why, one step back38def test_options_on_multiple_rules(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 39–43why, one step back39 @app.route("/", methods=["GET", "POST"])40 def index():41 return "Hello World"4243 @app.route("/", methods=["PUT"])Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 44why, one step back44 def index_put():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 45–50why, one step back45 return "Aha!"4647 rv = client.open("/", method="OPTIONS")48 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS", "POST", "PUT"]4950Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 51why, one step back51def test_provide_automatic_options_attr():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 52–56why, one step back52 app = flask.Flask(__name__)5354 def index():55 return "Hello World!"56Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 57why, one step back57 index.provide_automatic_options = FalseMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 58–66why, one step back58 app.route("/")(index)59 rv = app.test_client().open("/", method="OPTIONS")60 assert rv.status_code == 4056162 app = flask.Flask(__name__)6364 def index2():65 return "Hello World!"66Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 67why, one step back67 index2.provide_automatic_options = TrueMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 68–72why, one step back68 app.route("/", methods=["OPTIONS"])(index2)69 rv = app.test_client().open("/", method="OPTIONS")70 assert sorted(rv.allow) == ["OPTIONS"]7172Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 73why, one step back73def test_provide_automatic_options_kwarg(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 74–80why, one step back74 def index():75 return flask.request.method7677 def more():78 return flask.request.method7980 app.add_url_rule("/", view_func=index, provide_automatic_options=False)Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 81why, one step back81 app.add_url_rule(Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 82–92why, one step back82 "/more",83 view_func=more,84 methods=["GET", "POST"],85 provide_automatic_options=False,86 )87 assert client.get("/").data == b"GET"8889 rv = client.post("/")90 assert rv.status_code == 40591 assert sorted(rv.allow) == ["GET", "HEAD"]92Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 93why, one step back93 # Older versions of Werkzeug.test.Client don't have an options methodMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 94–118why, one step back94 if hasattr(client, "options"):95 rv = client.options("/")96 else:97 rv = client.open("/", method="OPTIONS")9899 assert rv.status_code == 405100101 rv = client.head("/")102 assert rv.status_code == 200103 assert not rv.data # head truncates104 assert client.post("/more").data == b"POST"105 assert client.get("/more").data == b"GET"106107 rv = client.delete("/more")108 assert rv.status_code == 405109 assert sorted(rv.allow) == ["GET", "HEAD", "POST"]110111 if hasattr(client, "options"):112 rv = client.options("/more")113 else:114 rv = client.open("/more", method="OPTIONS")115116 assert rv.status_code == 405117118Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 119why, one step back119def test_request_dispatching(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 120–141why, one step back120 @app.route("/")121 def index():122 return flask.request.method123124 @app.route("/more", methods=["GET", "POST"])125 def more():126 return flask.request.method127128 assert client.get("/").data == b"GET"129 rv = client.post("/")130 assert rv.status_code == 405131 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS"]132 rv = client.head("/")133 assert rv.status_code == 200134 assert not rv.data # head truncates135 assert client.post("/more").data == b"POST"136 assert client.get("/more").data == b"GET"137 rv = client.delete("/more")138 assert rv.status_code == 405139 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS", "POST"]140141Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 142–143why, one step back142def test_disallow_string_for_allowed_methods(app):143 with pytest.raises(TypeError):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 144–146why, one step back144145 @app.route("/", methods="GET POST")146 def index():Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 147why, one step back147 return "Hey"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 148–149why, one step back148149Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 150–151why, one step back150def test_url_mapping(app, client):151 random_uuid4 = "7eb41166-9ebf-4d26-b771-ea3f54f8b383"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 152–158why, one step back152153 def index():154 return flask.request.method155156 def more():157 return flask.request.method158Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 159–160why, one step back159 def options():160 return random_uuid4Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 161–164why, one step back161162 app.add_url_rule("/", "index", index)163 app.add_url_rule("/more", "more", more, methods=["GET", "POST"])164Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 165why, one step back165 # Issue 1288: Test that automatic options are not added when non-uppercase 'options' in methodsMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 166–181why, one step back166 app.add_url_rule("/options", "options", options, methods=["options"])167168 assert client.get("/").data == b"GET"169 rv = client.post("/")170 assert rv.status_code == 405171 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS"]172 rv = client.head("/")173 assert rv.status_code == 200174 assert not rv.data # head truncates175 assert client.post("/more").data == b"POST"176 assert client.get("/more").data == b"GET"177 rv = client.delete("/more")178 assert rv.status_code == 405179 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS", "POST"]180 rv = client.open("/options", method="OPTIONS")181 assert rv.status_code == 200Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 182why, one step back182 assert random_uuid4 in rv.data.decode("utf-8")Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 183–184why, one step back183184Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 185why, one step back185def test_werkzeug_routing(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 186–204why, one step back186 from werkzeug.routing import Submount, Rule187188 app.url_map.add(189 Submount("/foo", [Rule("/bar", endpoint="bar"), Rule("/", endpoint="index")])190 )191192 def bar():193 return "bar"194195 def index():196 return "index"197198 app.view_functions["bar"] = bar199 app.view_functions["index"] = index200201 assert client.get("/foo/").data == b"index"202 assert client.get("/foo/bar").data == b"bar"203204Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 205why, one step back205def test_endpoint_decorator(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 206–223why, one step back206 from werkzeug.routing import Submount, Rule207208 app.url_map.add(209 Submount("/foo", [Rule("/bar", endpoint="bar"), Rule("/", endpoint="index")])210 )211212 @app.endpoint("bar")213 def bar():214 return "bar"215216 @app.endpoint("index")217 def index():218 return "index"219220 assert client.get("/foo/").data == b"index"221 assert client.get("/foo/bar").data == b"bar"222223Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 224why, one step back224def test_session(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 225why, one step back225 @app.route("/set", methods=["POST"])Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 226why, one step back226 def set():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 227–230why, one step back227 assert not flask.session.accessed228 assert not flask.session.modified229 flask.session["value"] = flask.request.form["value"]230 assert flask.session.accessedMerge pull request #2580 from pallets/session-attrsDavid Lordbefore adoption26f413e
line 231why, one step back231 assert flask.session.modifiedMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 232–240why, one step back232 return "value set"233234 @app.route("/get")235 def get():236 assert not flask.session.accessed237 assert not flask.session.modified238 v = flask.session.get("value", "None")239 assert flask.session.accessed240 assert not flask.session.modifiedMerge pull request #2580 from pallets/session-attrsDavid Lordbefore adoption26f413e
line 241why, one step back241 return vMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 242–246why, one step back242243 assert client.post("/set", data={"value": "42"}).data == b"value set"244 assert client.get("/get").data == b"42"245246Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 247why, one step back247def test_session_using_server_name(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 248–259why, one step back248 app.config.update(SERVER_NAME="example.com")249250 @app.route("/")251 def index():252 flask.session["testing"] = 42253 return "Hello World"254255 rv = client.get("/", "http://example.com/")256 assert "domain=.example.com" in rv.headers["set-cookie"].lower()257 assert "httponly" in rv.headers["set-cookie"].lower()258259Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 260why, one step back260def test_session_using_server_name_and_port(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 261–272why, one step back261 app.config.update(SERVER_NAME="example.com:8080")262263 @app.route("/")264 def index():265 flask.session["testing"] = 42266 return "Hello World"267268 rv = client.get("/", "http://example.com:8080/")269 assert "domain=.example.com" in rv.headers["set-cookie"].lower()270 assert "httponly" in rv.headers["set-cookie"].lower()271272Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 273why, one step back273def test_session_using_server_name_port_and_path(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 274–286why, one step back274 app.config.update(SERVER_NAME="example.com:8080", APPLICATION_ROOT="/foo")275276 @app.route("/")277 def index():278 flask.session["testing"] = 42279 return "Hello World"280281 rv = client.get("/", "http://example.com:8080/foo")282 assert "domain=example.com" in rv.headers["set-cookie"].lower()283 assert "path=/foo" in rv.headers["set-cookie"].lower()284 assert "httponly" in rv.headers["set-cookie"].lower()285286Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 287–291why, one step back287def test_session_using_application_root(app, client):288 class PrefixPathMiddleware(object):289 def __init__(self, app, prefix):290 self.app = app291 self.prefix = prefixMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 292why, one step back292Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 293why, one step back293 def __call__(self, environ, start_response):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 294why, one step back294 environ["SCRIPT_NAME"] = self.prefixMerge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 295why, one step back295 return self.app(environ, start_response)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 296–308why, one step back296297 app.wsgi_app = PrefixPathMiddleware(app.wsgi_app, "/bar")298 app.config.update(APPLICATION_ROOT="/bar")299300 @app.route("/")301 def index():302 flask.session["testing"] = 42303 return "Hello World"304305 rv = client.get("/", "http://example.com:8080/")306 assert "path=/bar" in rv.headers["set-cookie"].lower()307308Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 309why, one step back309def test_session_using_session_settings(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 310–313why, one step back310 app.config.update(311 SERVER_NAME="www.example.com:8080",312 APPLICATION_ROOT="/test",313 SESSION_COOKIE_DOMAIN=".example.com",Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 314–315why, one step back314 SESSION_COOKIE_HTTPONLY=False,315 SESSION_COOKIE_SECURE=True,Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 316–333why, one step back316 SESSION_COOKIE_SAMESITE="Lax",317 SESSION_COOKIE_PATH="/",318 )319320 @app.route("/")321 def index():322 flask.session["testing"] = 42323 return "Hello World"324325 rv = client.get("/", "http://www.example.com:8080/test/")326 cookie = rv.headers["set-cookie"].lower()327 assert "domain=.example.com" in cookie328 assert "path=/" in cookie329 assert "secure" in cookie330 assert "httponly" not in cookie331 assert "samesite" in cookie332333Merge pull request #2607 from FadhelC/SameSite-cookie-featureDavid Lordbefore adoptione21abd9
line 334why, one step back334def test_session_using_samesite_attribute(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 335–341why, one step back335 @app.route("/")336 def index():337 flask.session["testing"] = 42338 return "Hello World"339340 app.config.update(SESSION_COOKIE_SAMESITE="invalid")341Merge pull request #2607 from FadhelC/SameSite-cookie-featureDavid Lordbefore adoptione21abd9
line 342why, one step back342 with pytest.raises(ValueError):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 343–344why, one step back343 client.get("/")344Merge pull request #2607 from FadhelC/SameSite-cookie-featureDavid Lordbefore adoptione21abd9
line 345why, one step back345 app.config.update(SESSION_COOKIE_SAMESITE=None)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 346–360why, one step back346 rv = client.get("/")347 cookie = rv.headers["set-cookie"].lower()348 assert "samesite" not in cookie349350 app.config.update(SESSION_COOKIE_SAMESITE="Strict")351 rv = client.get("/")352 cookie = rv.headers["set-cookie"].lower()353 assert "samesite=strict" in cookie354355 app.config.update(SESSION_COOKIE_SAMESITE="Lax")356 rv = client.get("/")357 cookie = rv.headers["set-cookie"].lower()358 assert "samesite=lax" in cookie359360Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 361why, one step back361def test_session_localhost_warning(recwarn, app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 362–371why, one step back362 app.config.update(SERVER_NAME="localhost:5000")363364 @app.route("/")365 def index():366 flask.session["testing"] = 42367 return "testing"368369 rv = client.get("/", "http://localhost:5000/")370 assert "domain" not in rv.headers["set-cookie"].lower()371 w = recwarn.pop(UserWarning)Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 372why, one step back372 assert '"localhost" is not a valid cookie domain' in str(w.message)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 373–374why, one step back373374Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 375why, one step back375def test_session_ip_warning(recwarn, app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 376–388why, one step back376 app.config.update(SERVER_NAME="127.0.0.1:5000")377378 @app.route("/")379 def index():380 flask.session["testing"] = 42381 return "testing"382383 rv = client.get("/", "http://127.0.0.1:5000/")384 assert "domain=127.0.0.1" in rv.headers["set-cookie"].lower()385 w = recwarn.pop(UserWarning)386 assert "cookie domain is an IP" in str(w.message)387388Merge pull request #2399 from davidism/docs-secret-keyDavid Lordbefore adoptiond13e41d
lines 389–390why, one step back389def test_missing_session(app):390 app.secret_key = NoneMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 391why, one step back391Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 392–393why, one step back392 def expect_exception(f, *args, **kwargs):393 e = pytest.raises(RuntimeError, f, *args, **kwargs)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 394–401why, one step back394 assert e.value.args and "session is unavailable" in e.value.args[0]395396 with app.test_request_context():397 assert flask.session.get("missing_key") is None398 expect_exception(flask.session.__setitem__, "foo", 42)399 expect_exception(flask.session.pop, "foo")400401Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 402–403why, one step back402def test_session_expiration(app, client):403 permanent = TrueMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 404–407why, one step back404405 @app.route("/")406 def index():407 flask.session["test"] = 42Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 408why, one step back408 flask.session.permanent = permanentMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 409–412why, one step back409 return ""410411 @app.route("/test")412 def test():Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 413why, one step back413 return text_type(flask.session.permanent)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 414–417why, one step back414415 rv = client.get("/")416 assert "set-cookie" in rv.headers417 match = re.search(r"(?i)\bexpires=([^;]+)", rv.headers["set-cookie"])Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 418–422why, one step back418 expires = parse_date(match.group())419 expected = datetime.utcnow() + app.permanent_session_lifetime420 assert expires.year == expected.year421 assert expires.month == expected.month422 assert expires.day == expected.dayMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 423–426why, one step back423424 rv = client.get("/test")425 assert rv.data == b"True"426Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 427why, one step back427 permanent = FalseMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 428–430why, one step back428 rv = client.get("/")429 assert "set-cookie" in rv.headers430 match = re.search(r"\bexpires=([^;]+)", rv.headers["set-cookie"])Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 431why, one step back431 assert match is NoneMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 432–433why, one step back432433Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 434why, one step back434def test_session_stored_last(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 435why, one step back435 @app.after_requestMerge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 436why, one step back436 def modify_session(response):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 437–447why, one step back437 flask.session["foo"] = 42438 return response439440 @app.route("/")441 def dump_session_contents():442 return repr(flask.session.get("foo"))443444 assert client.get("/").data == b"None"445 assert client.get("/").data == b"42"446447Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 448–450why, one step back448def test_session_special_types(app, client):449 now = datetime.utcnow().replace(microsecond=0)450 the_uuid = uuid.uuid4()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 451–465why, one step back451452 @app.route("/")453 def dump_session_contents():454 flask.session["t"] = (1, 2, 3)455 flask.session["b"] = b"\xff"456 flask.session["m"] = flask.Markup("<html>")457 flask.session["u"] = the_uuid458 flask.session["d"] = now459 flask.session["t_tag"] = {" t": "not-a-tuple"}460 flask.session["di_t_tag"] = {" t__": "not-a-tuple"}461 flask.session["di_tag"] = {" di": "not-a-dict"}462 return "", 204463464 with client:465 client.get("/")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 466why, one step back466 s = flask.sessionMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 467–478why, one step back467 assert s["t"] == (1, 2, 3)468 assert type(s["b"]) == bytes469 assert s["b"] == b"\xff"470 assert type(s["m"]) == flask.Markup471 assert s["m"] == flask.Markup("<html>")472 assert s["u"] == the_uuid473 assert s["d"] == now474 assert s["t_tag"] == {" t": "not-a-tuple"}475 assert s["di_t_tag"] == {" t__": "not-a-tuple"}476 assert s["di_tag"] == {" di": "not-a-dict"}477478Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 479why, one step back479def test_session_cookie_setting(app):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 480–482why, one step back480 is_permanent = True481482 @app.route("/bump")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 483why, one step back483 def bump():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 484why, one step back484 rv = flask.session["foo"] = flask.session.get("foo", 0) + 1Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 485–486why, one step back485 flask.session.permanent = is_permanent486 return str(rv)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 487–488why, one step back487488 @app.route("/read")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 489why, one step back489 def read():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 490–491why, one step back490 return str(flask.session.get("foo", 0))491Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 492–493why, one step back492 def run_test(expect_header):493 with app.test_client() as c:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 494–499why, one step back494 assert c.get("/bump").data == b"1"495 assert c.get("/bump").data == b"2"496 assert c.get("/bump").data == b"3"497498 rv = c.get("/read")499 set_cookie = rv.headers.get("set-cookie")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 500why, one step back500 assert (set_cookie is not None) == expect_headerMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 501–504why, one step back501 assert rv.data == b"3"502503 is_permanent = True504 app.config["SESSION_REFRESH_EACH_REQUEST"] = TrueMerge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 505why, one step back505 run_test(expect_header=True)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 506–519why, one step back506507 is_permanent = True508 app.config["SESSION_REFRESH_EACH_REQUEST"] = False509 run_test(expect_header=False)510511 is_permanent = False512 app.config["SESSION_REFRESH_EACH_REQUEST"] = True513 run_test(expect_header=False)514515 is_permanent = False516 app.config["SESSION_REFRESH_EACH_REQUEST"] = False517 run_test(expect_header=False)518519Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 520why, one step back520def test_session_vary_cookie(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 521why, one step back521 @app.route("/set")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 522why, one step back522 def set_session():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 523–530why, one step back523 flask.session["test"] = "test"524 return ""525526 @app.route("/get")527 def get():528 return flask.session.get("test")529530 @app.route("/getitem")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 531why, one step back531 def getitem():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 532–534why, one step back532 return flask.session["test"]533534 @app.route("/setdefault")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 535why, one step back535 def setdefault():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 536–538why, one step back536 return flask.session.setdefault("test", "default")537538 @app.route("/vary-cookie-header-set")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 539why, one step back539 def vary_cookie_header_set():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 540–545why, one step back540 response = flask.Response()541 response.vary.add("Cookie")542 flask.session["test"] = "test"543 return response544545 @app.route("/vary-header-set")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 546why, one step back546 def vary_header_set():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 547–552why, one step back547 response = flask.Response()548 response.vary.update(("Accept-Encoding", "Accept-Language"))549 flask.session["test"] = "test"550 return response551552 @app.route("/no-vary-header")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 553why, one step back553 def no_vary_header():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 554–556why, one step back554 return ""555556 def expect(path, header_value="Cookie"):Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 557why, one step back557 rv = client.get(path)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 558why, one step back558Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 559–560why, one step back559 if header_value:560 # The 'Vary' key should exist in the headers only once.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 561–574why, one step back561 assert len(rv.headers.get_all("Vary")) == 1562 assert rv.headers["Vary"] == header_value563 else:564 assert "Vary" not in rv.headers565566 expect("/set")567 expect("/get")568 expect("/getitem")569 expect("/setdefault")570 expect("/vary-cookie-header-set")571 expect("/vary-header-set", "Accept-Encoding, Accept-Language, Cookie")572 expect("/no-vary-header", None)573574Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 575–576why, one step back575def test_flashes(app, req_ctx):576 assert not flask.session.modifiedMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 577why, one step back577 flask.flash("Zap")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 578why, one step back578 flask.session.modified = FalseMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 579why, one step back579 flask.flash("Zip")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 580why, one step back580 assert flask.session.modifiedMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 581–583why, one step back581 assert list(flask.get_flashed_messages()) == ["Zap", "Zip"]582583Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 584–589why, one step back584def test_extended_flashing(app):585 # Be sure app.testing=True below, else tests can fail silently.586 #587 # Specifically, if app.testing is not set to True, the AssertionErrors588 # in the view functions will cause a 500 response to the test client589 # instead of propagating exceptions.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 590–599why, one step back590591 @app.route("/")592 def index():593 flask.flash(u"Hello World")594 flask.flash(u"Hello World", "error")595 flask.flash(flask.Markup(u"<em>Testing</em>"), "warning")596 return ""597598 @app.route("/test/")599 def test():Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 600why, one step back600 messages = flask.get_flashed_messages()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 601–608why, one step back601 assert list(messages) == [602 u"Hello World",603 u"Hello World",604 flask.Markup(u"<em>Testing</em>"),605 ]606 return ""607608 @app.route("/test_with_categories/")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 609–611why, one step back609 def test_with_categories():610 messages = flask.get_flashed_messages(with_categories=True)611 assert len(messages) == 3Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 612–619why, one step back612 assert list(messages) == [613 ("message", u"Hello World"),614 ("error", u"Hello World"),615 ("warning", flask.Markup(u"<em>Testing</em>")),616 ]617 return ""618619 @app.route("/test_filter/")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 620why, one step back620 def test_filter():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 621–627why, one step back621 messages = flask.get_flashed_messages(622 category_filter=["message"], with_categories=True623 )624 assert list(messages) == [("message", u"Hello World")]625 return ""626627 @app.route("/test_filters/")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 628why, one step back628 def test_filters():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 629–638why, one step back629 messages = flask.get_flashed_messages(630 category_filter=["message", "warning"], with_categories=True631 )632 assert list(messages) == [633 ("message", u"Hello World"),634 ("warning", flask.Markup(u"<em>Testing</em>")),635 ]636 return ""637638 @app.route("/test_filters_without_returning_categories/")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 639why, one step back639 def test_filters2():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 640why, one step back640 messages = flask.get_flashed_messages(category_filter=["message", "warning"])Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 641why, one step back641 assert len(messages) == 2Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 642–645why, one step back642 assert messages[0] == u"Hello World"643 assert messages[1] == flask.Markup(u"<em>Testing</em>")644 return ""645Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 646why, one step back646 # Create new test client on each test to clean flashed messages.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 647–664why, one step back647648 client = app.test_client()649 client.get("/")650 client.get("/test_with_categories/")651652 client = app.test_client()653 client.get("/")654 client.get("/test_filter/")655656 client = app.test_client()657 client.get("/")658 client.get("/test_filters/")659660 client = app.test_client()661 client.get("/")662 client.get("/test_filters_without_returning_categories/")663664Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 665why, one step back665def test_request_processing(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 666–689why, one step back666 evts = []667668 @app.before_request669 def before_request():670 evts.append("before")671672 @app.after_request673 def after_request(response):674 response.data += b"|after"675 evts.append("after")676 return response677678 @app.route("/")679 def index():680 assert "before" in evts681 assert "after" not in evts682 return "request"683684 assert "after" not in evts685 rv = client.get("/").data686 assert "after" in evts687 assert rv == b"request|after"688689Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 690why, one step back690def test_request_preprocessing_early_return(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 691–693why, one step back691 evts = []692693 @app.before_requestMerge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 694–695why, one step back694 def before_request1():695 evts.append(1)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 696–697why, one step back696697 @app.before_requestMerge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 698–700why, one step back698 def before_request2():699 evts.append(2)700 return "hello"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 701–702why, one step back701702 @app.before_requestMerge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 703–705why, one step back703 def before_request3():704 evts.append(3)705 return "bye"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 706–709why, one step back706707 @app.route("/")708 def index():709 evts.append("index")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 710why, one step back710 return "damnit"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 711–713why, one step back711712 rv = client.get("/").data.strip()713 assert rv == b"hello"Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 714why, one step back714 assert evts == [1, 2]Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 715–716why, one step back715716Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 717why, one step back717def test_after_request_processing(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 718–719why, one step back718 @app.route("/")719 def index():Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 720–721why, one step back720 @flask.after_this_request721 def foo(response):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 722why, one step back722 response.headers["X-Foo"] = "a header"Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 723why, one step back723 return responseMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 724–727why, one step back724725 return "Test"726727 resp = client.get("/")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 728why, one step back728 assert resp.status_code == 200Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 729–731why, one step back729 assert resp.headers["X-Foo"] == "a header"730731Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 732why, one step back732def test_teardown_request_handler(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 733–749why, one step back733 called = []734735 @app.teardown_request736 def teardown_request(exc):737 called.append(True)738 return "Ignored"739740 @app.route("/")741 def root():742 return "Response"743744 rv = client.get("/")745 assert rv.status_code == 200746 assert b"Response" in rv.data747 assert len(called) == 1748749Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 750why, one step back750def test_teardown_request_handler_debug_mode(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 751–767why, one step back751 called = []752753 @app.teardown_request754 def teardown_request(exc):755 called.append(True)756 return "Ignored"757758 @app.route("/")759 def root():760 return "Response"761762 rv = client.get("/")763 assert rv.status_code == 200764 assert b"Response" in rv.data765 assert len(called) == 1766767Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 768why, one step back768def test_teardown_request_handler_error(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 769–772why, one step back769 called = []770 app.testing = False771772 @app.teardown_requestMerge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 773why, one step back773 def teardown_request1(exc):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 774–784why, one step back774 assert type(exc) == ZeroDivisionError775 called.append(True)776 # This raises a new error and blows away sys.exc_info(), so we can777 # test that all teardown_requests get passed the same original778 # exception.779 try:780 raise TypeError()781 except:782 pass783784 @app.teardown_requestMerge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 785why, one step back785 def teardown_request2(exc):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 786–796why, one step back786 assert type(exc) == ZeroDivisionError787 called.append(True)788 # This raises a new error and blows away sys.exc_info(), so we can789 # test that all teardown_requests get passed the same original790 # exception.791 try:792 raise TypeError()793 except:794 pass795796 @app.route("/")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 797why, one step back797 def fails():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 798–802why, one step back798 1 // 0799800 rv = client.get("/")801 assert rv.status_code == 500802 assert b"Internal Server Error" in rv.dataMerge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 803why, one step back803 assert len(called) == 2Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 804–805why, one step back804805Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 806why, one step back806def test_before_after_request_order(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 807–809why, one step back807 called = []808809 @app.before_requestMerge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 810–811why, one step back810 def before1():811 called.append(1)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 812–813why, one step back812813 @app.before_requestMerge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 814–815why, one step back814 def before2():815 called.append(2)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 816–817why, one step back816817 @app.after_requestMerge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 818–819why, one step back818 def after1(response):819 called.append(4)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 820–822why, one step back820 return response821822 @app.after_requestMerge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 823–824why, one step back823 def after2(response):824 called.append(3)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 825–827why, one step back825 return response826827 @app.teardown_requestMerge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 828–829why, one step back828 def finish1(exc):829 called.append(6)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 830–831why, one step back830831 @app.teardown_requestMerge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 832–833why, one step back832 def finish2(exc):833 called.append(5)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 834–840why, one step back834835 @app.route("/")836 def index():837 return "42"838839 rv = client.get("/")840 assert rv.data == b"42"Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 841why, one step back841 assert called == [1, 2, 3, 4, 5, 6]Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 842–843why, one step back842843Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 844why, one step back844def test_error_handling(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 845–847why, one step back845 app.testing = False846847 @app.errorhandler(404)Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 848why, one step back848 def not_found(e):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 849–854why, one step back849 return "not found", 404850851 @app.errorhandler(500)852 def internal_server_error(e):853 return "internal server error", 500854Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 855–856why, one step back855 @app.errorhandler(Forbidden)856 def forbidden(e):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 857–863why, one step back857 return "forbidden", 403858859 @app.route("/")860 def index():861 flask.abort(404)862863 @app.route("/error")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 864why, one step back864 def error():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 865–867why, one step back865 1 // 0866867 @app.route("/forbidden")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 868why, one step back868 def error2():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 869–877why, one step back869 flask.abort(403)870871 rv = client.get("/")872 assert rv.status_code == 404873 assert rv.data == b"not found"874 rv = client.get("/error")875 assert rv.status_code == 500876 assert b"internal server error" == rv.data877 rv = client.get("/forbidden")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 878why, one step back878 assert rv.status_code == 403Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 879–881why, one step back879 assert b"forbidden" == rv.data880881Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 882–883why, one step back882def test_error_handler_unknown_code(app):883 with pytest.raises(KeyError) as exc_info:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 884–888why, one step back884 app.register_error_handler(999, lambda e: ("999", 999))885886 assert "Use a subclass" in exc_info.value.args[0]887888Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 889why, one step back889def test_error_handling_processing(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 890–900why, one step back890 app.testing = False891892 @app.errorhandler(500)893 def internal_server_error(e):894 return "internal server error", 500895896 @app.route("/")897 def broken_func():898 1 // 0899900 @app.after_requestMerge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 901why, one step back901 def after_request(resp):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 902why, one step back902 resp.mimetype = "text/x-special"Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 903why, one step back903 return respMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 904–909why, one step back904905 resp = client.get("/")906 assert resp.mimetype == "text/x-special"907 assert resp.data == b"internal server error"908909Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 910why, one step back910def test_baseexception_error_handling(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 911–914why, one step back911 app.testing = False912913 @app.route("/")914 def broken_func():Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 915why, one step back915 raise KeyboardInterrupt()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 916why, one step back916Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 917why, one step back917 with pytest.raises(KeyboardInterrupt):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 918–919why, one step back918 client.get("/")919Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 920–922why, one step back920 ctx = flask._request_ctx_stack.top921 assert ctx.preserved922 assert type(ctx._preserved_exc) is KeyboardInterruptMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 923–924why, one step back923924Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 925why, one step back925def test_before_request_and_routing_errors(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 926why, one step back926 @app.before_requestMerge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 927why, one step back927 def attach_something():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 928–930why, one step back928 flask.g.something = "value"929930 @app.errorhandler(404)Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 931–932why, one step back931 def return_something(error):932 return flask.g.something, 404Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 933–938why, one step back933934 rv = client.get("/")935 assert rv.status_code == 404936 assert rv.data == b"value"937938Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 939–940why, one step back939def test_user_error_handling(app, client):940 class MyException(Exception):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 941–942why, one step back941 pass942Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 943–945why, one step back943 @app.errorhandler(MyException)944 def handle_my_exception(e):945 assert isinstance(e, MyException)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 946–949why, one step back946 return "42"947948 @app.route("/")949 def index():Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 950why, one step back950 raise MyException()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 951–954why, one step back951952 assert client.get("/").data == b"42"953954Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 955–956why, one step back955def test_http_error_subclass_handling(app, client):956 class ForbiddenSubclass(Forbidden):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 957–958why, one step back957 pass958Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 959why, one step back959 @app.errorhandler(ForbiddenSubclass)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 960why, one step back960 def handle_forbidden_subclass(e):Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 961why, one step back961 assert isinstance(e, ForbiddenSubclass)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 962–963why, one step back962 return "banana"963Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 964why, one step back964 @app.errorhandler(403)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 965why, one step back965 def handle_forbidden_subclass(e):Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 966–967why, one step back966 assert not isinstance(e, ForbiddenSubclass)967 assert isinstance(e, Forbidden)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 968–970why, one step back968 return "apple"969970 @app.route("/1")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 971–972why, one step back971 def index1():972 raise ForbiddenSubclass()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 973–978why, one step back973974 @app.route("/2")975 def index2():976 flask.abort(403)977978 @app.route("/3")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 979–980why, one step back979 def index3():980 raise Forbidden()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 981–986why, one step back981982 assert client.get("/1").data == b"banana"983 assert client.get("/2").data == b"apple"984 assert client.get("/3").data == b"apple"985986Merge pull request #2362 from davidism/remove-error-handler-cacheDavid Lordbefore adoptionb80cf05
lines 987–988why, one step back987def test_errorhandler_precedence(app, client):988 class E1(Exception):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 989–990why, one step back989 pass990Merge pull request #2362 from davidism/remove-error-handler-cacheDavid Lordbefore adoptionb80cf05
line 991why, one step back991 class E2(Exception):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 992–993why, one step back992 pass993Merge pull request #2362 from davidism/remove-error-handler-cacheDavid Lordbefore adoptionb80cf05
line 994why, one step back994 class E3(E1, E2):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 995–996why, one step back995 pass996Merge pull request #2362 from davidism/remove-error-handler-cacheDavid Lordbefore adoptionb80cf05
lines 997–998why, one step back997 @app.errorhandler(E2)998 def handle_e2(e):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 999–1000why, one step back999 return "E2"1000Merge pull request #2362 from davidism/remove-error-handler-cacheDavid Lordbefore adoptionb80cf05
lines 1001–1002why, one step back1001 @app.errorhandler(Exception)1002 def handle_exception(e):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1003–1005why, one step back1003 return "Exception"10041005 @app.route("/E1")Merge pull request #2362 from davidism/remove-error-handler-cacheDavid Lordbefore adoptionb80cf05
lines 1006–1007why, one step back1006 def raise_e1():1007 raise E1Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1008–1009why, one step back10081009 @app.route("/E3")Merge pull request #2362 from davidism/remove-error-handler-cacheDavid Lordbefore adoptionb80cf05
lines 1010–1011why, one step back1010 def raise_e3():1011 raise E3Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1012–1019why, one step back10121013 rv = client.get("/E1")1014 assert rv.data == b"Exception"10151016 rv = client.get("/E3")1017 assert rv.data == b"E2"10181019Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1020why, one step back1020def test_trapping_of_bad_request_key_errors(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1021–1025why, one step back1021 @app.route("/key")1022 def fail():1023 flask.request.form["missing_key"]10241025 @app.route("/abort")Merge branch '1.0-maintenance'David Lordbefore adoption1fa9185
lines 1026–1027why, one step back1026 def allow_abort():1027 flask.abort(400)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1028–1035why, one step back10281029 rv = client.get("/key")1030 assert rv.status_code == 4001031 assert b"missing_key" not in rv.data1032 rv = client.get("/abort")1033 assert rv.status_code == 40010341035 app.debug = TrueMerge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1036why, one step back1036 with pytest.raises(KeyError) as e:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1037why, one step back1037 client.get("/key")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1038why, one step back1038 assert e.errisinstance(BadRequest)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1039–1044why, one step back1039 assert "missing_key" in e.value.get_description()1040 rv = client.get("/abort")1041 assert rv.status_code == 40010421043 app.debug = False1044 app.config["TRAP_BAD_REQUEST_ERRORS"] = TrueMerge branch '1.0-maintenance'David Lordbefore adoption1fa9185
line 1045why, one step back1045 with pytest.raises(KeyError):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1046why, one step back1046 client.get("/key")Merge branch '1.0-maintenance'David Lordbefore adoption1fa9185
line 1047why, one step back1047 with pytest.raises(BadRequest):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1048–1050why, one step back1048 client.get("/abort")10491050Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1051why, one step back1051def test_trapping_of_all_http_exceptions(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1052–1057why, one step back1052 app.config["TRAP_HTTP_EXCEPTIONS"] = True10531054 @app.route("/fail")1055 def fail():1056 flask.abort(404)1057Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1058why, one step back1058 with pytest.raises(NotFound):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1059–1061why, one step back1059 client.get("/fail")10601061Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469
line 1062why, one step back1062def test_error_handler_after_processor_error(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1063–1085why, one step back1063 app.testing = False10641065 @app.before_request1066 def before_request():1067 if trigger == "before":1068 1 // 010691070 @app.after_request1071 def after_request(response):1072 if trigger == "after":1073 1 // 01074 return response10751076 @app.route("/")1077 def index():1078 return "Foo"10791080 @app.errorhandler(500)1081 def internal_server_error(e):1082 return "Hello Server Error", 50010831084 for trigger in "before", "after":1085 rv = client.get("/")Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469
line 1086why, one step back1086 assert rv.status_code == 500Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1087–1089why, one step back1087 assert rv.data == b"Hello Server Error"10881089Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 1090–1091why, one step back1090def test_enctype_debug_helper(app, client):1091 from flask.debughelpers import DebugFilesKeyErrorMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1092–1098why, one step back10921093 app.debug = True10941095 @app.route("/fail", methods=["POST"])1096 def index():1097 return flask.request.files["foo"].filename1098Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 1099–1101why, one step back1099 # with statement is important because we leave an exception on the1100 # stack otherwise and we want to ensure that this is not the case1101 # to not negatively affect other tests.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1102why, one step back1102 with client:Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1103why, one step back1103 with pytest.raises(DebugFilesKeyError) as e:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1104–1105why, one step back1104 client.post("/fail", data={"foo": "index.txt"})1105 assert "no file contents were transmitted" in str(e.value)Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1106why, one step back1106 assert 'This was submitted: "index.txt"' in str(e.value)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1107–1108why, one step back11071108Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1109why, one step back1109def test_response_types(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1110why, one step back1110 @app.route("/text")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1111why, one step back1111 def from_text():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1112–1114why, one step back1112 return u"Hällo Wörld"11131114 @app.route("/bytes")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1115why, one step back1115 def from_bytes():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1116–1118why, one step back1116 return u"Hällo Wörld".encode("utf-8")11171118 @app.route("/full_tuple")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1119why, one step back1119 def from_full_tuple():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1120–1126why, one step back1120 return (1121 "Meh",1122 400,1123 {"X-Foo": "Testing", "Content-Type": "text/plain; charset=utf-8"},1124 )11251126 @app.route("/text_headers")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1127why, one step back1127 def from_text_headers():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1128–1130why, one step back1128 return "Hello", {"X-Foo": "Test", "Content-Type": "text/plain; charset=utf-8"}11291130 @app.route("/text_status")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1131why, one step back1131 def from_text_status():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1132–1134why, one step back1132 return "Hi, status!", 40011331134 @app.route("/response_headers")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1135why, one step back1135 def from_response_headers():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1136–1141why, one step back1136 return (1137 flask.Response("Hello world", 404, {"X-Foo": "Baz"}),1138 {"X-Foo": "Bar", "X-Bar": "Foo"},1139 )11401141 @app.route("/response_status")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1142why, one step back1142 def from_response_status():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1143–1145why, one step back1143 return app.response_class("Hello world", 400), 50011441145 @app.route("/wsgi")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 1146–1147why, one step back1146 def from_wsgi():1147 return NotFound()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1148–1183why, one step back11481149 assert client.get("/text").data == u"Hällo Wörld".encode("utf-8")1150 assert client.get("/bytes").data == u"Hällo Wörld".encode("utf-8")11511152 rv = client.get("/full_tuple")1153 assert rv.data == b"Meh"1154 assert rv.headers["X-Foo"] == "Testing"1155 assert rv.status_code == 4001156 assert rv.mimetype == "text/plain"11571158 rv = client.get("/text_headers")1159 assert rv.data == b"Hello"1160 assert rv.headers["X-Foo"] == "Test"1161 assert rv.status_code == 2001162 assert rv.mimetype == "text/plain"11631164 rv = client.get("/text_status")1165 assert rv.data == b"Hi, status!"1166 assert rv.status_code == 4001167 assert rv.mimetype == "text/html"11681169 rv = client.get("/response_headers")1170 assert rv.data == b"Hello world"1171 assert rv.headers.getlist("X-Foo") == ["Baz", "Bar"]1172 assert rv.headers["X-Bar"] == "Foo"1173 assert rv.status_code == 40411741175 rv = client.get("/response_status")1176 assert rv.data == b"Hello world"1177 assert rv.status_code == 50011781179 rv = client.get("/wsgi")1180 assert b"Not Found" in rv.data1181 assert rv.status_code == 40411821183Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1184why, one step back1184def test_response_type_errors():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1185–1188why, one step back1185 app = flask.Flask(__name__)1186 app.testing = True11871188 @app.route("/none")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1189why, one step back1189 def from_none():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1190–1192why, one step back1190 pass11911192 @app.route("/small_tuple")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1193why, one step back1193 def from_small_tuple():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1194–1196why, one step back1194 return ("Hello",)11951196 @app.route("/large_tuple")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1197why, one step back1197 def from_large_tuple():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1198–1200why, one step back1198 return "Hello", 234, {"X-Foo": "Bar"}, "???"11991200 @app.route("/bad_type")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 1201–1202why, one step back1201 def from_bad_type():1202 return TrueMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1203–1204why, one step back12031204 @app.route("/bad_wsgi")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 1205–1206why, one step back1205 def from_bad_wsgi():1206 return lambda: NoneMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1207–1226why, one step back12071208 c = app.test_client()12091210 with pytest.raises(TypeError) as e:1211 c.get("/none")1212 assert "returned None" in str(e)12131214 with pytest.raises(TypeError) as e:1215 c.get("/small_tuple")1216 assert "tuple must have the form" in str(e)12171218 pytest.raises(TypeError, c.get, "/large_tuple")12191220 with pytest.raises(TypeError) as e:1221 c.get("/bad_type")1222 assert "it was a bool" in str(e)12231224 pytest.raises(TypeError, c.get, "/bad_wsgi")12251226Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 1227–1228why, one step back1227def test_make_response(app, req_ctx):1228 rv = flask.make_response()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1229–1243why, one step back1229 assert rv.status_code == 2001230 assert rv.data == b""1231 assert rv.mimetype == "text/html"12321233 rv = flask.make_response("Awesome")1234 assert rv.status_code == 2001235 assert rv.data == b"Awesome"1236 assert rv.mimetype == "text/html"12371238 rv = flask.make_response("W00t", 404)1239 assert rv.status_code == 4041240 assert rv.data == b"W00t"1241 assert rv.mimetype == "text/html"12421243Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1244why, one step back1244def test_make_response_with_response_instance(app, req_ctx):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1245–1246why, one step back1245 rv = flask.make_response(flask.jsonify({"msg": "W00t"}), 400)1246 assert rv.status_code == 400Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1247why, one step back1247 assert rv.data == b'{"msg":"W00t"}\n'Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1248–1264why, one step back1248 assert rv.mimetype == "application/json"12491250 rv = flask.make_response(flask.Response(""), 400)1251 assert rv.status_code == 4001252 assert rv.data == b""1253 assert rv.mimetype == "text/html"12541255 rv = flask.make_response(1256 flask.Response("", headers={"Content-Type": "text/html"}),1257 400,1258 [("X-Foo", "bar")],1259 )1260 assert rv.status_code == 4001261 assert rv.headers["Content-Type"] == "text/html"1262 assert rv.headers["X-Foo"] == "bar"12631264Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 1265–1267why, one step back1265def test_jsonify_no_prettyprint(app, req_ctx):1266 app.config.update({"JSONIFY_PRETTYPRINT_REGULAR": False})1267 compressed_msg = b'{"msg":{"submsg":"W00t"},"msg2":"foobar"}\n'Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1268–1270why, one step back1268 uncompressed_msg = {"msg": {"submsg": "W00t"}, "msg2": "foobar"}12691270 rv = flask.make_response(flask.jsonify(uncompressed_msg), 200)Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1271why, one step back1271 assert rv.data == compressed_msgMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1272–1273why, one step back12721273Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 1274–1276why, one step back1274def test_jsonify_prettyprint(app, req_ctx):1275 app.config.update({"JSONIFY_PRETTYPRINT_REGULAR": True})1276 compressed_msg = {"msg": {"submsg": "W00t"}, "msg2": "foobar"}Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1277why, one step back1277 pretty_response = (Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1278why, one step back1278 b'{\n "msg": {\n "submsg": "W00t"\n }, \n "msg2": "foobar"\n}\n'Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1279–1281why, one step back1279 )12801281 rv = flask.make_response(flask.jsonify(compressed_msg), 200)Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1282why, one step back1282 assert rv.data == pretty_responseMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1283–1284why, one step back12831284Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1285why, one step back1285def test_jsonify_mimetype(app, req_ctx):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1286–1291why, one step back1286 app.config.update({"JSONIFY_MIMETYPE": "application/vnd.api+json"})1287 msg = {"msg": {"submsg": "W00t"}}1288 rv = flask.make_response(flask.jsonify(msg), 200)1289 assert rv.mimetype == "application/vnd.api+json"12901291Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1292why, one step back1292def test_jsonify_args_and_kwargs_check(app, req_ctx):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1293–1297why, one step back1293 with pytest.raises(TypeError) as e:1294 flask.jsonify("fake args", kwargs="fake")1295 assert "behavior undefined" in str(e.value)12961297Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1298why, one step back1298def test_url_generation(app, req_ctx):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1299why, one step back1299 @app.route("/hello/<name>", methods=["POST"])Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1300why, one step back1300 def hello():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1301–1309why, one step back1301 pass13021303 assert flask.url_for("hello", name="test x") == "/hello/test%20x"1304 assert (1305 flask.url_for("hello", name="test x", _external=True)1306 == "http://localhost/hello/test%20x"1307 )13081309Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 1310–1311why, one step back1310def test_build_error_handler(app):1311 # Test base case, a URL which results in a BuildError.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1312–1314why, one step back1312 with app.test_request_context():1313 pytest.raises(BuildError, flask.url_for, "spam")1314Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1315why, one step back1315 # Verify the error is re-raised if not the current exception.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1316why, one step back1316 try:Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1317why, one step back1317 with app.test_request_context():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1318why, one step back1318 flask.url_for("spam")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 1319–1320why, one step back1319 except BuildError as err:1320 error = errMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1321–1322why, one step back1321 try:1322 raise RuntimeError("Test case where BuildError is not current.")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1323why, one step back1323 except RuntimeError:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1324–1325why, one step back1324 pytest.raises(BuildError, app.handle_url_build_error, error, "spam", {})1325Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1326why, one step back1326 # Test a custom handler.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1327why, one step back1327 def handler(error, endpoint, values):Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1328why, one step back1328 # Just a test.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1329–1330why, one step back1329 return "/test_handler/"1330Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1331why, one step back1331 app.url_build_error_handlers.append(handler)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1332–1335why, one step back1332 with app.test_request_context():1333 assert flask.url_for("spam") == "/test_handler/"13341335Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 1336–1339why, one step back1336def test_build_error_handler_reraise(app):1337 # Test a custom handler which reraises the BuildError1338 def handler_raises_build_error(error, endpoint, values):1339 raise errorMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1340why, one step back1340Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1341why, one step back1341 app.url_build_error_handlers.append(handler_raises_build_error)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1342–1346why, one step back13421343 with app.test_request_context():1344 pytest.raises(BuildError, flask.url_for, "not.existing")13451346Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 1347–1348why, one step back1347def test_url_for_passes_special_values_to_build_error_handler(app):1348 @app.url_build_error_handlers.appendMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1349why, one step back1349 def handler(error, endpoint, values):Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1350why, one step back1350 assert values == {Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1351–1361why, one step back1351 "_external": False,1352 "_anchor": None,1353 "_method": None,1354 "_scheme": None,1355 }1356 return "handled"13571358 with app.test_request_context():1359 flask.url_for("/")13601361Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 1362–1363why, one step back1362def test_custom_converters(app, client):1363 from werkzeug.routing import BaseConverterMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1364why, one step back1364Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 1365–1366why, one step back1365 class ListConverter(BaseConverter):1366 def to_python(self, value):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1367–1368why, one step back1367 return value.split(",")1368Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 1369–1370why, one step back1369 def to_url(self, value):1370 base_to_url = super(ListConverter, self).to_urlMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1371–1375why, one step back1371 return ",".join(base_to_url(x) for x in value)13721373 app.url_map.converters["list"] = ListConverter13741375 @app.route("/<list:args>")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1376why, one step back1376 def index(args):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1377–1381why, one step back1377 return "|".join(args)13781379 assert client.get("/1,2,3").data == b"1|2|3"13801381Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1382why, one step back1382def test_static_files(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1383–1390why, one step back1383 rv = client.get("/static/index.html")1384 assert rv.status_code == 2001385 assert rv.data.strip() == b"<h1>Hello World!</h1>"1386 with app.test_request_context():1387 assert flask.url_for("static", filename="index.html") == "/static/index.html"1388 rv.close()13891390Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1391why, one step back1391def test_static_url_path():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1392–1401why, one step back1392 app = flask.Flask(__name__, static_url_path="/foo")1393 app.testing = True1394 rv = app.test_client().get("/foo/index.html")1395 assert rv.status_code == 2001396 rv.close()13971398 with app.test_request_context():1399 assert flask.url_for("static", filename="index.html") == "/foo/index.html"14001401Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1402why, one step back1402def test_static_route_with_host_matching():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1403–1410why, one step back1403 app = flask.Flask(__name__, host_matching=True, static_host="example.com")1404 c = app.test_client()1405 rv = c.get("http://example.com/static/index.html")1406 assert rv.status_code == 2001407 rv.close()1408 with app.test_request_context():1409 rv = flask.url_for("static", filename="index.html", _external=True)1410 assert rv == "http://example.com/static/index.html"Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1411why, one step back1411 # Providing static_host without host_matching=True should error.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1412–1413why, one step back1412 with pytest.raises(Exception):1413 flask.Flask(__name__, static_host="example.com")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1414why, one step back1414 # Providing host_matching=True with static_folder but without static_host should error.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1415why, one step back1415 with pytest.raises(Exception):Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 1416–1418why, one step back1416 flask.Flask(__name__, host_matching=True)1417 # Providing host_matching=True without static_host but with static_folder=None should not error.1418 flask.Flask(__name__, host_matching=True, static_folder=None)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1419–1420why, one step back14191420Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1421why, one step back1421def test_request_locals():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1422why, one step back1422 assert repr(flask.g) == "<LocalProxy unbound>"Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1423why, one step back1423 assert not flask.gMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1424–1425why, one step back14241425Merge pull request #2635 from pallets/feature/server-name-routingDavid Lordbefore adoptionf808c20
line 1426why, one step back1426def test_test_app_proper_environ():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1427–1435why, one step back1427 app = flask.Flask(__name__, subdomain_matching=True)1428 app.config.update(SERVER_NAME="localhost.localdomain:5000")1429 client = app.test_client()14301431 @app.route("/")1432 def index():1433 return "Foo"14341435 @app.route("/", subdomain="foo")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1436why, one step back1436 def subdomain():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1437–1460why, one step back1437 return "Foo SubDomain"14381439 rv = client.get("/")1440 assert rv.data == b"Foo"14411442 rv = client.get("/", "http://localhost.localdomain:5000")1443 assert rv.data == b"Foo"14441445 rv = client.get("/", "https://localhost.localdomain:5000")1446 assert rv.data == b"Foo"14471448 app.config.update(SERVER_NAME="localhost.localdomain")1449 rv = client.get("/", "https://localhost.localdomain")1450 assert rv.data == b"Foo"14511452 try:1453 app.config.update(SERVER_NAME="localhost.localdomain:443")1454 rv = client.get("/", "https://localhost.localdomain")1455 # Werkzeug 0.81456 assert rv.status_code == 4041457 except ValueError as e:1458 # Werkzeug 0.71459 assert str(e) == (1460 "the server name provided "Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 1461–1462why, one step back1461 "('localhost.localdomain:443') does not match the "1462 "server name from the WSGI environment ('localhost.localdomain')"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1463–1473why, one step back1463 )14641465 try:1466 app.config.update(SERVER_NAME="localhost.localdomain")1467 rv = client.get("/", "http://foo.localhost")1468 # Werkzeug 0.81469 assert rv.status_code == 4041470 except ValueError as e:1471 # Werkzeug 0.71472 assert str(e) == (1473 "the server name provided "Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 1474–1475why, one step back1474 "('localhost.localdomain') does not match the "1475 "server name from the WSGI environment ('foo.localhost')"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1476–1481why, one step back1476 )14771478 rv = client.get("/", "http://foo.localhost.localdomain")1479 assert rv.data == b"Foo SubDomain"14801481Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 1482–1483why, one step back1482def test_exception_propagation(app, client):1483 def apprunner(config_key):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1484–1487why, one step back1484 @app.route("/")1485 def index():1486 1 // 01487Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 1488–1490why, one step back1488 if config_key is not None:1489 app.config[config_key] = True1490 with pytest.raises(Exception):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1491–1494why, one step back1491 client.get("/")1492 else:1493 assert client.get("/").status_code == 5001494Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 1495–1498why, one step back1495 # we have to run this test in an isolated thread because if the1496 # debug flag is set to true and an exception happens the context is1497 # not torn down. This causes other tests that run after this fail1498 # when they expect no exception on the stack.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1499why, one step back1499 for config_key in "TESTING", "PROPAGATE_EXCEPTIONS", "DEBUG", None:Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 1500–1502why, one step back1500 t = Thread(target=apprunner, args=(config_key,))1501 t.start()1502 t.join()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1503–1519why, one step back150315041505@pytest.mark.parametrize("debug", [True, False])1506@pytest.mark.parametrize("use_debugger", [True, False])1507@pytest.mark.parametrize("use_reloader", [True, False])1508@pytest.mark.parametrize("propagate_exceptions", [None, True, False])1509def test_werkzeug_passthrough_errors(1510 monkeypatch, debug, use_debugger, use_reloader, propagate_exceptions, app1511):1512 rv = {}15131514 # Mocks werkzeug.serving.run_simple method1515 def run_simple_mock(*args, **kwargs):1516 rv["passthrough_errors"] = kwargs.get("passthrough_errors")15171518 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)1519 app.config["PROPAGATE_EXCEPTIONS"] = propagate_exceptionsMerge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1520why, one step back1520 app.run(debug=debug, use_debugger=use_debugger, use_reloader=use_reloader)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1521–1522why, one step back15211522Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1523why, one step back1523def test_max_content_length(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1524–1526why, one step back1524 app.config["MAX_CONTENT_LENGTH"] = 6415251526 @app.before_requestMerge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1527why, one step back1527 def always_first():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1528–1531why, one step back1528 flask.request.form["myfile"]1529 assert False15301531 @app.route("/accept", methods=["POST"])Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1532why, one step back1532 def accept_file():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1533–1535why, one step back1533 flask.request.form["myfile"]1534 assert False1535Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 1536–1537why, one step back1536 @app.errorhandler(413)1537 def catcher(error):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1538–1543why, one step back1538 return "42"15391540 rv = client.post("/accept", data={"myfile": "foo" * 100})1541 assert rv.data == b"42"15421543Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 1544–1546why, one step back1544def test_url_processors(app, client):1545 @app.url_defaults1546 def add_language_code(endpoint, values):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1547–1551why, one step back1547 if flask.g.lang_code is not None and app.url_map.is_endpoint_expecting(1548 endpoint, "lang_code"1549 ):1550 values.setdefault("lang_code", flask.g.lang_code)1551Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 1552–1553why, one step back1552 @app.url_value_preprocessor1553 def pull_lang_code(endpoint, values):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1554–1560why, one step back1554 flask.g.lang_code = values.pop("lang_code", None)15551556 @app.route("/<lang_code>/")1557 def index():1558 return flask.url_for("about")15591560 @app.route("/<lang_code>/about")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1561why, one step back1561 def about():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1562–1564why, one step back1562 return flask.url_for("something_else")15631564 @app.route("/foo")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1565why, one step back1565 def something_else():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1566–1572why, one step back1566 return flask.url_for("about", lang_code="en")15671568 assert client.get("/de/").data == b"/de/about"1569 assert client.get("/de/about").data == b"/foo"1570 assert client.get("/foo").data == b"/en/about"15711572Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1573why, one step back1573def test_inject_blueprint_url_defaults(app):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1574–1575why, one step back1574 bp = flask.Blueprint("foo.bar.baz", __name__, template_folder="template")1575Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 1576–1577why, one step back1576 @bp.url_defaults1577 def bp_defaults(endpoint, values):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1578–1580why, one step back1578 values["page"] = "login"15791580 @bp.route("/<page>")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1581why, one step back1581 def view(page):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1582–1583why, one step back1582 pass1583Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1584why, one step back1584 app.register_blueprint(bp)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1585why, one step back1585Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1586why, one step back1586 values = dict()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1587–1588why, one step back1587 app.inject_url_defaults("foo.bar.baz.view", values)1588 expected = dict(page="login")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1589why, one step back1589 assert values == expectedMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1590–1593why, one step back15901591 with app.test_request_context("/somepage"):1592 url = flask.url_for("foo.bar.baz.view")1593 expected = "/login"Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1594why, one step back1594 assert url == expectedMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1595–1596why, one step back15951596Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1597why, one step back1597def test_nonascii_pathinfo(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1598–1605why, one step back1598 @app.route(u"/киртест")1599 def index():1600 return "Hello World!"16011602 rv = client.get(u"/киртест")1603 assert rv.data == b"Hello World!"16041605Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1606why, one step back1606def test_debug_mode_complains_after_first_request(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1607–1612why, one step back1607 app.debug = True16081609 @app.route("/")1610 def index():1611 return "Awesome"1612Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1613why, one step back1613 assert not app.got_first_requestMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1614why, one step back1614 assert client.get("/").data == b"Awesome"Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1615why, one step back1615 with pytest.raises(AssertionError) as e:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1616–1617why, one step back16161617 @app.route("/foo")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1618why, one step back1618 def broken():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1619–1625why, one step back1619 return "Meh"16201621 assert "A setup function was called" in str(e)16221623 app.debug = False16241625 @app.route("/foo")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1626why, one step back1626 def working():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1627–1632why, one step back1627 return "Meh"16281629 assert client.get("/foo").data == b"Meh"1630 assert app.got_first_request16311632Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1633why, one step back1633def test_before_first_request_functions(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1634–1646why, one step back1634 got = []16351636 @app.before_first_request1637 def foo():1638 got.append(42)16391640 client.get("/")1641 assert got == [42]1642 client.get("/")1643 assert got == [42]1644 assert app.got_first_request16451646Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1647why, one step back1647def test_before_first_request_functions_concurrent(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1648–1651why, one step back1648 got = []16491650 @app.before_first_request1651 def foo():Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1652why, one step back1652 time.sleep(0.2)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1653–1654why, one step back1653 got.append(42)1654Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1655why, one step back1655 def get_and_assert():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1656why, one step back1656 client.get("/")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1657why, one step back1657 assert got == [42]Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1658why, one step back1658Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 1659–1662why, one step back1659 t = Thread(target=get_and_assert)1660 t.start()1661 get_and_assert()1662 t.join()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1663–1665why, one step back1663 assert app.got_first_request16641665Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1666why, one step back1666def test_routing_redirect_debugging(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1667–1673why, one step back1667 app.debug = True16681669 @app.route("/foo/", methods=["GET", "POST"])1670 def foo():1671 return "success"16721673 with client:Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1674why, one step back1674 with pytest.raises(AssertionError) as e:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1675–1687why, one step back1675 client.post("/foo", data={})1676 assert "http://localhost/foo/" in str(e)1677 assert ("Make sure to directly send " "your POST-request to this URL") in str(e)16781679 rv = client.get("/foo", data={}, follow_redirects=True)1680 assert rv.data == b"success"16811682 app.debug = False1683 with client:1684 rv = client.post("/foo", data={}, follow_redirects=True)1685 assert rv.data == b"success"16861687Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1688why, one step back1688def test_route_decorator_custom_endpoint(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1689–1695why, one step back1689 app.debug = True16901691 @app.route("/foo/")1692 def foo():1693 return flask.request.endpoint16941695 @app.route("/bar/", endpoint="bar")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1696why, one step back1696 def for_bar():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1697–1699why, one step back1697 return flask.request.endpoint16981699 @app.route("/bar/123", endpoint="123")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1700why, one step back1700 def for_bar_foo():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1701–1712why, one step back1701 return flask.request.endpoint17021703 with app.test_request_context():1704 assert flask.url_for("foo") == "/foo/"1705 assert flask.url_for("bar") == "/bar/"1706 assert flask.url_for("123") == "/bar/123"17071708 assert client.get("/foo/").data == b"foo"1709 assert client.get("/bar/").data == b"bar"1710 assert client.get("/bar/123").data == b"123"17111712Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1713why, one step back1713def test_preserve_only_once(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1714–1719why, one step back1714 app.debug = True17151716 @app.route("/fail")1717 def fail_func():1718 1 // 01719Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 1720–1721why, one step back1720 for x in range(3):1721 with pytest.raises(ZeroDivisionError):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1722–1723why, one step back1722 client.get("/fail")1723Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 1724–1729why, one step back1724 assert flask._request_ctx_stack.top is not None1725 assert flask._app_ctx_stack.top is not None1726 # implicit appctx disappears too1727 flask._request_ctx_stack.top.pop()1728 assert flask._request_ctx_stack.top is None1729 assert flask._app_ctx_stack.top is NoneMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1730–1731why, one step back17301731Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1732why, one step back1732def test_preserve_remembers_exception(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1733why, one step back1733 app.debug = TrueMerge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1734why, one step back1734 errors = []Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1735–1740why, one step back17351736 @app.route("/fail")1737 def fail_func():1738 1 // 017391740 @app.route("/success")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1741why, one step back1741 def success_func():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1742–1744why, one step back1742 return "Okay"17431744 @app.teardown_requestMerge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 1745–1746why, one step back1745 def teardown_handler(exc):1746 errors.append(exc)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1747why, one step back1747Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 1748–1749why, one step back1748 # After this failure we did not yet call the teardown handler1749 with pytest.raises(ZeroDivisionError):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1750why, one step back1750 client.get("/fail")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1751why, one step back1751 assert errors == []Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1752why, one step back1752Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1753why, one step back1753 # But this request triggers it, and it's an errorMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1754why, one step back1754 client.get("/success")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 1755–1756why, one step back1755 assert len(errors) == 21756 assert isinstance(errors[0], ZeroDivisionError)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1757why, one step back1757Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1758why, one step back1758 # At this point another request does nothing.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1759why, one step back1759 client.get("/success")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 1760–1761why, one step back1760 assert len(errors) == 31761 assert errors[1] is NoneMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1762–1763why, one step back17621763Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1764why, one step back1764def test_get_method_on_g(app_ctx):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1765–1766why, one step back1765 assert flask.g.get("x") is None1766 assert flask.g.get("x", 11) == 11Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1767why, one step back1767 flask.g.x = 42Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1768why, one step back1768 assert flask.g.get("x") == 42Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1769why, one step back1769 assert flask.g.x == 42Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1770–1771why, one step back17701771Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 1772–1774why, one step back1772def test_g_iteration_protocol(app_ctx):1773 flask.g.foo = 231774 flask.g.bar = 42Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1775–1779why, one step back1775 assert "foo" in flask.g1776 assert "foos" not in flask.g1777 assert sorted(flask.g) == ["bar", "foo"]17781779Merge pull request #2635 from pallets/feature/server-name-routingDavid Lordbefore adoptionf808c20
line 1780why, one step back1780def test_subdomain_basic_support():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1781–1785why, one step back1781 app = flask.Flask(__name__, subdomain_matching=True)1782 app.config["SERVER_NAME"] = "localhost.localdomain"1783 client = app.test_client()17841785 @app.route("/")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1786why, one step back1786 def normal_index():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1787–1789why, one step back1787 return "normal index"17881789 @app.route("/", subdomain="test")Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1790why, one step back1790 def test_index():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1791–1799why, one step back1791 return "test index"17921793 rv = client.get("/", "http://localhost.localdomain/")1794 assert rv.data == b"normal index"17951796 rv = client.get("/", "http://test.localhost.localdomain/")1797 assert rv.data == b"test index"17981799Merge pull request #2635 from pallets/feature/server-name-routingDavid Lordbefore adoptionf808c20
line 1800why, one step back1800def test_subdomain_matching():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1801–1812why, one step back1801 app = flask.Flask(__name__, subdomain_matching=True)1802 client = app.test_client()1803 app.config["SERVER_NAME"] = "localhost.localdomain"18041805 @app.route("/", subdomain="<user>")1806 def index(user):1807 return "index for %s" % user18081809 rv = client.get("/", "http://mitsuhiko.localhost.localdomain/")1810 assert rv.data == b"index for mitsuhiko"18111812Merge pull request #2635 from pallets/feature/server-name-routingDavid Lordbefore adoptionf808c20
line 1813why, one step back1813def test_subdomain_matching_with_ports():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1814–1826why, one step back1814 app = flask.Flask(__name__, subdomain_matching=True)1815 app.config["SERVER_NAME"] = "localhost.localdomain:3000"1816 client = app.test_client()18171818 @app.route("/", subdomain="<user>")1819 def index(user):1820 return "index for %s" % user18211822 rv = client.get("/", "http://mitsuhiko.localhost.localdomain:3000/")1823 assert rv.data == b"index for mitsuhiko"182418251826@pytest.mark.parametrize("matching", (False, True))Merge pull request #2635 from pallets/feature/server-name-routingDavid Lordbefore adoptionf808c20
lines 1827–1828why, one step back1827def test_subdomain_matching_other_name(matching):1828 app = flask.Flask(__name__, subdomain_matching=matching)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1829–1835why, one step back1829 app.config["SERVER_NAME"] = "localhost.localdomain:3000"1830 client = app.test_client()18311832 @app.route("/")1833 def index():1834 return "", 2041835Merge pull request #2635 from pallets/feature/server-name-routingDavid Lordbefore adoptionf808c20
line 1836why, one step back1836 # ip address can't match nameMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1837–1839why, one step back1837 rv = client.get("/", "http://127.0.0.1:3000/")1838 assert rv.status_code == 404 if matching else 2041839Merge pull request #2635 from pallets/feature/server-name-routingDavid Lordbefore adoptionf808c20
line 1840why, one step back1840 # allow all subdomains if matching is disabledMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1841–1844why, one step back1841 rv = client.get("/", "http://www.localhost.localdomain:3000/")1842 assert rv.status_code == 404 if matching else 20418431844Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1845why, one step back1845def test_multi_route_rules(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1846–1848why, one step back1846 @app.route("/")1847 @app.route("/<test>/")1848 def index(test="a"):Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1849why, one step back1849 return testMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1850–1856why, one step back18501851 rv = client.open("/")1852 assert rv.data == b"a"1853 rv = client.open("/b/")1854 assert rv.data == b"b"18551856Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 1857–1859why, one step back1857def test_multi_route_class_views(app, client):1858 class View(object):1859 def __init__(self, app):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1860–1863why, one step back1860 app.add_url_rule("/", "index", self.index)1861 app.add_url_rule("/<test>/", "index", self.index)18621863 def index(self, test="a"):Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1864why, one step back1864 return testMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1865why, one step back1865Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1866why, one step back1866 _ = View(app)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1867–1872why, one step back1867 rv = client.open("/")1868 assert rv.data == b"a"1869 rv = client.open("/b/")1870 assert rv.data == b"b"18711872Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1873why, one step back1873def test_run_defaults(monkeypatch, app):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1874–1880why, one step back1874 rv = {}18751876 # Mocks werkzeug.serving.run_simple method1877 def run_simple_mock(*args, **kwargs):1878 rv["result"] = "running..."18791880 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1881why, one step back1881 app.run()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1882–1884why, one step back1882 assert rv["result"] == "running..."18831884Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1885why, one step back1885def test_run_server_port(monkeypatch, app):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1886–1888why, one step back1886 rv = {}18871888 # Mocks werkzeug.serving.run_simple methodMerge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1889why, one step back1889 def run_simple_mock(hostname, port, application, *args, **kwargs):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1890–1893why, one step back1890 rv["result"] = "running on %s:%s ..." % (hostname, port)18911892 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)1893 hostname, port = "localhost", 8000Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1894why, one step back1894 app.run(hostname, port, debug=True)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1895–1906why, one step back1895 assert rv["result"] == "running on %s:%s ..." % (hostname, port)189618971898@pytest.mark.parametrize(1899 "host,port,expect_host,expect_port",1900 (1901 (None, None, "pocoo.org", 8080),1902 ("localhost", None, "localhost", 8080),1903 (None, 80, "pocoo.org", 80),1904 ("localhost", 80, "localhost", 80),1905 ),1906)Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
lines 1907–1910why, one step back1907def test_run_from_config(monkeypatch, host, port, expect_host, expect_port, app):1908 def run_simple_mock(hostname, port, *args, **kwargs):1909 assert hostname == expect_host1910 assert port == expect_portMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1911–1913why, one step back19111912 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)1913 app.config["SERVER_NAME"] = "pocoo.org:8080"Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96
line 1914why, one step back1914 app.run(host, port)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1915–1916why, one step back19151916Merge pull request #2693 from davidism/max-cookie-sizeDavid Lordbefore adoptiond8bf589
line 1917why, one step back1917def test_max_cookie_size(app, client, recwarn):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1918–1919why, one step back1918 app.config["MAX_COOKIE_SIZE"] = 1001919Merge pull request #2693 from davidism/max-cookie-sizeDavid Lordbefore adoptiond8bf589
lines 1920–1922why, one step back1920 # outside app context, default to Werkzeug static value,1921 # which is also the default config1922 response = flask.Response()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1923why, one step back1923 default = flask.Flask.default_config["MAX_COOKIE_SIZE"]Merge pull request #2693 from davidism/max-cookie-sizeDavid Lordbefore adoptiond8bf589
line 1924why, one step back1924 assert response.max_cookie_size == defaultMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1925why, one step back1925Merge pull request #2693 from davidism/max-cookie-sizeDavid Lordbefore adoptiond8bf589
lines 1926–1928why, one step back1926 # inside app context, use app config1927 with app.app_context():1928 assert flask.Response().max_cookie_size == 100Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1929–1933why, one step back19291930 @app.route("/")1931 def index():1932 r = flask.Response("", status=204)1933 r.set_cookie("foo", "bar" * 100)Merge pull request #2693 from davidism/max-cookie-sizeDavid Lordbefore adoptiond8bf589
line 1934why, one step back1934 return rMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1935–1936why, one step back19351936 client.get("/")Merge pull request #2693 from davidism/max-cookie-sizeDavid Lordbefore adoptiond8bf589
lines 1937–1938why, one step back1937 assert len(recwarn) == 11938 w = recwarn.pop()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1939–1943why, one step back1939 assert "cookie is too large" in str(w.message)19401941 app.config["MAX_COOKIE_SIZE"] = 019421943 client.get("/")Merge pull request #2693 from davidism/max-cookie-sizeDavid Lordbefore adoptiond8bf589
line 1944why, one step back1944 assert len(recwarn) == 0