test_basic.py
This file
Path
tests/test_basic.py
2,010 lines · 54.0 KiB · Python
Last changed by
include samesite and secure when removing session cookie (#3726)Mathurshan Vimalesvaranbefore adoption22987b6
History of this fileTake it
The walk stopped after 200 commits: lines older than b78ebac point at it.
Break reference cycle created by default in Flask instances.Bogdan Opanchukbefore adoption8efea0c
line 1why, one step back1import gcMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 2why, one step back2import reMerge pull request #3195 from eruvanos/json_support_dataclassDavid Lordbefore adoptionb0185a6
line 3why, one step back3import sysMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 4–5why, one step back4import time5import uuidBreak reference cycle created by default in Flask instances.Bogdan Opanchukbefore adoption8efea0c
line 6why, one step back6import weakrefMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 7why, one step back7from datetime import datetimeBreak reference cycle created by default in Flask instances.Bogdan Opanchukbefore adoption8efea0c
line 8why, one step back8from platform import python_implementationMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 9–12why, one step back9from threading import Thread1011import pytest12import werkzeug.servingMerge pull request #3246 from pallets/reorder-importsDavid Lordbefore adoption3db4697
lines 13–15why, one step back13from werkzeug.exceptions import BadRequest14from werkzeug.exceptions import Forbidden15from werkzeug.exceptions import NotFoundMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 16–21why, one step back16from werkzeug.http import parse_date17from werkzeug.routing import BuildError1819import flask2021Break reference cycle created by default in Flask instances.Bogdan Opanchukbefore adoption8efea0c
line 22why, one step back22require_cpython_gc = pytest.mark.skipif(update requirements (#3823)David Lordbefore adoption373f0dd
lines 23–24why, one step back23 python_implementation() != "CPython",24 reason="Requires CPython GC behavior",Break reference cycle created by default in Flask instances.Bogdan Opanchukbefore adoption8efea0c
lines 25–27why, one step back25)2627Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 28why, one step back28def 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 #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
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 #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
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 #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
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 #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
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 #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
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 #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
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 #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
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 #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 93why, one step back93 rv = client.open("/", method="OPTIONS")Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 94–105why, one step back94 assert rv.status_code == 4059596 rv = client.head("/")97 assert rv.status_code == 20098 assert not rv.data # head truncates99 assert client.post("/more").data == b"POST"100 assert client.get("/more").data == b"GET"101102 rv = client.delete("/more")103 assert rv.status_code == 405104 assert sorted(rv.allow) == ["GET", "HEAD", "POST"]105Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 106why, one step back106 rv = client.open("/more", method="OPTIONS")Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 107–109why, one step back107 assert rv.status_code == 405108109Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 110why, one step back110def test_request_dispatching(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 111–132why, one step back111 @app.route("/")112 def index():113 return flask.request.method114115 @app.route("/more", methods=["GET", "POST"])116 def more():117 return flask.request.method118119 assert client.get("/").data == b"GET"120 rv = client.post("/")121 assert rv.status_code == 405122 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS"]123 rv = client.head("/")124 assert rv.status_code == 200125 assert not rv.data # head truncates126 assert client.post("/more").data == b"POST"127 assert client.get("/more").data == b"GET"128 rv = client.delete("/more")129 assert rv.status_code == 405130 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS", "POST"]131132Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 133–134why, one step back133def test_disallow_string_for_allowed_methods(app):134 with pytest.raises(TypeError):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 135–137why, one step back135136 @app.route("/", methods="GET POST")137 def index():Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 138why, one step back138 return "Hey"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 139–140why, one step back139140Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 141–142why, one step back141def test_url_mapping(app, client):142 random_uuid4 = "7eb41166-9ebf-4d26-b771-ea3f54f8b383"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 143–149why, one step back143144 def index():145 return flask.request.method146147 def more():148 return flask.request.method149Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 150–151why, one step back150 def options():151 return random_uuid4Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 152–155why, one step back152153 app.add_url_rule("/", "index", index)154 app.add_url_rule("/more", "more", more, methods=["GET", "POST"])155Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86
lines 156–157why, one step back156 # Issue 1288: Test that automatic options are not added157 # when non-uppercase 'options' in methodsMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 158–173why, one step back158 app.add_url_rule("/options", "options", options, methods=["options"])159160 assert client.get("/").data == b"GET"161 rv = client.post("/")162 assert rv.status_code == 405163 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS"]164 rv = client.head("/")165 assert rv.status_code == 200166 assert not rv.data # head truncates167 assert client.post("/more").data == b"POST"168 assert client.get("/more").data == b"GET"169 rv = client.delete("/more")170 assert rv.status_code == 405171 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS", "POST"]172 rv = client.open("/options", method="OPTIONS")173 assert rv.status_code == 200Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 174why, one step back174 assert random_uuid4 in rv.data.decode("utf-8")Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 175–176why, one step back175176Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 177why, one step back177def test_werkzeug_routing(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 178–196why, one step back178 from werkzeug.routing import Submount, Rule179180 app.url_map.add(181 Submount("/foo", [Rule("/bar", endpoint="bar"), Rule("/", endpoint="index")])182 )183184 def bar():185 return "bar"186187 def index():188 return "index"189190 app.view_functions["bar"] = bar191 app.view_functions["index"] = index192193 assert client.get("/foo/").data == b"index"194 assert client.get("/foo/bar").data == b"bar"195196Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 197why, one step back197def test_endpoint_decorator(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 198–215why, one step back198 from werkzeug.routing import Submount, Rule199200 app.url_map.add(201 Submount("/foo", [Rule("/bar", endpoint="bar"), Rule("/", endpoint="index")])202 )203204 @app.endpoint("bar")205 def bar():206 return "bar"207208 @app.endpoint("index")209 def index():210 return "index"211212 assert client.get("/foo/").data == b"index"213 assert client.get("/foo/bar").data == b"bar"214215Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 216why, one step back216def test_session(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 217why, one step back217 @app.route("/set", methods=["POST"])Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 218why, one step back218 def set():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 219–222why, one step back219 assert not flask.session.accessed220 assert not flask.session.modified221 flask.session["value"] = flask.request.form["value"]222 assert flask.session.accessedMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 223why, one step back223 assert flask.session.modifiedMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 224–232why, one step back224 return "value set"225226 @app.route("/get")227 def get():228 assert not flask.session.accessed229 assert not flask.session.modified230 v = flask.session.get("value", "None")231 assert flask.session.accessed232 assert not flask.session.modifiedMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 233why, one step back233 return vMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 234–238why, one step back234235 assert client.post("/set", data={"value": "42"}).data == b"value set"236 assert client.get("/get").data == b"42"237238Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 239why, one step back239def test_session_using_server_name(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 240–251why, one step back240 app.config.update(SERVER_NAME="example.com")241242 @app.route("/")243 def index():244 flask.session["testing"] = 42245 return "Hello World"246247 rv = client.get("/", "http://example.com/")248 assert "domain=.example.com" in rv.headers["set-cookie"].lower()249 assert "httponly" in rv.headers["set-cookie"].lower()250251Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 252why, one step back252def test_session_using_server_name_and_port(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 253–264why, one step back253 app.config.update(SERVER_NAME="example.com:8080")254255 @app.route("/")256 def index():257 flask.session["testing"] = 42258 return "Hello World"259260 rv = client.get("/", "http://example.com:8080/")261 assert "domain=.example.com" in rv.headers["set-cookie"].lower()262 assert "httponly" in rv.headers["set-cookie"].lower()263264Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 265why, one step back265def test_session_using_server_name_port_and_path(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 266–278why, one step back266 app.config.update(SERVER_NAME="example.com:8080", APPLICATION_ROOT="/foo")267268 @app.route("/")269 def index():270 flask.session["testing"] = 42271 return "Hello World"272273 rv = client.get("/", "http://example.com:8080/foo")274 assert "domain=example.com" in rv.headers["set-cookie"].lower()275 assert "path=/foo" in rv.headers["set-cookie"].lower()276 assert "httponly" in rv.headers["set-cookie"].lower()277278Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 279why, one step back279def test_session_using_application_root(app, client):Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 280why, one step back280 class PrefixPathMiddleware:Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 281–283why, one step back281 def __init__(self, app, prefix):282 self.app = app283 self.prefix = prefixMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 284why, one step back284Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 285why, one step back285 def __call__(self, environ, start_response):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 286why, one step back286 environ["SCRIPT_NAME"] = self.prefixMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 287why, one step back287 return self.app(environ, start_response)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 288–300why, one step back288289 app.wsgi_app = PrefixPathMiddleware(app.wsgi_app, "/bar")290 app.config.update(APPLICATION_ROOT="/bar")291292 @app.route("/")293 def index():294 flask.session["testing"] = 42295 return "Hello World"296297 rv = client.get("/", "http://example.com:8080/")298 assert "path=/bar" in rv.headers["set-cookie"].lower()299300Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 301why, one step back301def test_session_using_session_settings(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 302–305why, one step back302 app.config.update(303 SERVER_NAME="www.example.com:8080",304 APPLICATION_ROOT="/test",305 SESSION_COOKIE_DOMAIN=".example.com",Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 306–307why, one step back306 SESSION_COOKIE_HTTPONLY=False,307 SESSION_COOKIE_SECURE=True,Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 308–324why, one step back308 SESSION_COOKIE_SAMESITE="Lax",309 SESSION_COOKIE_PATH="/",310 )311312 @app.route("/")313 def index():314 flask.session["testing"] = 42315 return "Hello World"316317 rv = client.get("/", "http://www.example.com:8080/test/")318 cookie = rv.headers["set-cookie"].lower()319 assert "domain=.example.com" in cookie320 assert "path=/" in cookie321 assert "secure" in cookie322 assert "httponly" not in cookie323 assert "samesite" in cookie324include samesite and secure when removing session cookie (#3726)Mathurshan Vimalesvaranbefore adoption22987b6
lines 325–337why, one step back325 @app.route("/clear")326 def clear():327 flask.session.pop("testing", None)328 return "Goodbye World"329330 rv = client.get("/clear", "http://www.example.com:8080/test/")331 cookie = rv.headers["set-cookie"].lower()332 assert "session=;" in cookie333 assert "domain=.example.com" in cookie334 assert "path=/" in cookie335 assert "secure" in cookie336 assert "samesite" in cookie337Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 338why, one step back338Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 339why, one step back339def test_session_using_samesite_attribute(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 340–346why, one step back340 @app.route("/")341 def index():342 flask.session["testing"] = 42343 return "Hello World"344345 app.config.update(SESSION_COOKIE_SAMESITE="invalid")346Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 347why, one step back347 with pytest.raises(ValueError):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 348–349why, one step back348 client.get("/")349Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 350why, one step back350 app.config.update(SESSION_COOKIE_SAMESITE=None)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 351–365why, one step back351 rv = client.get("/")352 cookie = rv.headers["set-cookie"].lower()353 assert "samesite" not in cookie354355 app.config.update(SESSION_COOKIE_SAMESITE="Strict")356 rv = client.get("/")357 cookie = rv.headers["set-cookie"].lower()358 assert "samesite=strict" in cookie359360 app.config.update(SESSION_COOKIE_SAMESITE="Lax")361 rv = client.get("/")362 cookie = rv.headers["set-cookie"].lower()363 assert "samesite=lax" in cookie364365Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 366why, one step back366def test_session_localhost_warning(recwarn, app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 367–376why, one step back367 app.config.update(SERVER_NAME="localhost:5000")368369 @app.route("/")370 def index():371 flask.session["testing"] = 42372 return "testing"373374 rv = client.get("/", "http://localhost:5000/")375 assert "domain" not in rv.headers["set-cookie"].lower()376 w = recwarn.pop(UserWarning)Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 377why, one step back377 assert "'localhost' is not a valid cookie domain" in str(w.message)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 378–379why, one step back378379Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 380why, one step back380def test_session_ip_warning(recwarn, app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 381–393why, one step back381 app.config.update(SERVER_NAME="127.0.0.1:5000")382383 @app.route("/")384 def index():385 flask.session["testing"] = 42386 return "testing"387388 rv = client.get("/", "http://127.0.0.1:5000/")389 assert "domain=127.0.0.1" in rv.headers["set-cookie"].lower()390 w = recwarn.pop(UserWarning)391 assert "cookie domain is an IP" in str(w.message)392393Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 394–395why, one step back394def test_missing_session(app):395 app.secret_key = NoneMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 396why, one step back396Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 397–398why, one step back397 def expect_exception(f, *args, **kwargs):398 e = pytest.raises(RuntimeError, f, *args, **kwargs)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 399–406why, one step back399 assert e.value.args and "session is unavailable" in e.value.args[0]400401 with app.test_request_context():402 assert flask.session.get("missing_key") is None403 expect_exception(flask.session.__setitem__, "foo", 42)404 expect_exception(flask.session.pop, "foo")405406Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 407–408why, one step back407def test_session_expiration(app, client):408 permanent = TrueMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 409–412why, one step back409410 @app.route("/")411 def index():412 flask.session["test"] = 42Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 413why, one step back413 flask.session.permanent = permanentMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 414–417why, one step back414 return ""415416 @app.route("/test")417 def test():Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 418why, one step back418 return str(flask.session.permanent)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 419–422why, one step back419420 rv = client.get("/")421 assert "set-cookie" in rv.headers422 match = re.search(r"(?i)\bexpires=([^;]+)", rv.headers["set-cookie"])Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 423–427why, one step back423 expires = parse_date(match.group())424 expected = datetime.utcnow() + app.permanent_session_lifetime425 assert expires.year == expected.year426 assert expires.month == expected.month427 assert expires.day == expected.dayMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 428–431why, one step back428429 rv = client.get("/test")430 assert rv.data == b"True"431Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 432why, one step back432 permanent = FalseMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 433–435why, one step back433 rv = client.get("/")434 assert "set-cookie" in rv.headers435 match = re.search(r"\bexpires=([^;]+)", rv.headers["set-cookie"])Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 436why, one step back436 assert match is NoneMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 437–438why, one step back437438Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 439why, one step back439def test_session_stored_last(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 440why, one step back440 @app.after_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 441why, one step back441 def modify_session(response):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 442–452why, one step back442 flask.session["foo"] = 42443 return response444445 @app.route("/")446 def dump_session_contents():447 return repr(flask.session.get("foo"))448449 assert client.get("/").data == b"None"450 assert client.get("/").data == b"42"451452Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 453–455why, one step back453def test_session_special_types(app, client):454 now = datetime.utcnow().replace(microsecond=0)455 the_uuid = uuid.uuid4()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 456–470why, one step back456457 @app.route("/")458 def dump_session_contents():459 flask.session["t"] = (1, 2, 3)460 flask.session["b"] = b"\xff"461 flask.session["m"] = flask.Markup("<html>")462 flask.session["u"] = the_uuid463 flask.session["d"] = now464 flask.session["t_tag"] = {" t": "not-a-tuple"}465 flask.session["di_t_tag"] = {" t__": "not-a-tuple"}466 flask.session["di_tag"] = {" di": "not-a-dict"}467 return "", 204468469 with client:470 client.get("/")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 471why, one step back471 s = flask.sessionMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 472–483why, one step back472 assert s["t"] == (1, 2, 3)473 assert type(s["b"]) == bytes474 assert s["b"] == b"\xff"475 assert type(s["m"]) == flask.Markup476 assert s["m"] == flask.Markup("<html>")477 assert s["u"] == the_uuid478 assert s["d"] == now479 assert s["t_tag"] == {" t": "not-a-tuple"}480 assert s["di_t_tag"] == {" t__": "not-a-tuple"}481 assert s["di_tag"] == {" di": "not-a-dict"}482483Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 484why, one step back484def test_session_cookie_setting(app):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 485–487why, one step back485 is_permanent = True486487 @app.route("/bump")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 488why, one step back488 def bump():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 489why, one step back489 rv = flask.session["foo"] = flask.session.get("foo", 0) + 1Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 490–491why, one step back490 flask.session.permanent = is_permanent491 return str(rv)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 492–493why, one step back492493 @app.route("/read")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 494why, one step back494 def read():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 495–496why, one step back495 return str(flask.session.get("foo", 0))496Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 497–498why, one step back497 def run_test(expect_header):498 with app.test_client() as c:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 499–504why, one step back499 assert c.get("/bump").data == b"1"500 assert c.get("/bump").data == b"2"501 assert c.get("/bump").data == b"3"502503 rv = c.get("/read")504 set_cookie = rv.headers.get("set-cookie")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 505why, one step back505 assert (set_cookie is not None) == expect_headerMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 506–509why, one step back506 assert rv.data == b"3"507508 is_permanent = True509 app.config["SESSION_REFRESH_EACH_REQUEST"] = TrueMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 510why, one step back510 run_test(expect_header=True)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 511–524why, one step back511512 is_permanent = True513 app.config["SESSION_REFRESH_EACH_REQUEST"] = False514 run_test(expect_header=False)515516 is_permanent = False517 app.config["SESSION_REFRESH_EACH_REQUEST"] = True518 run_test(expect_header=False)519520 is_permanent = False521 app.config["SESSION_REFRESH_EACH_REQUEST"] = False522 run_test(expect_header=False)523524Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 525why, one step back525def test_session_vary_cookie(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 526why, one step back526 @app.route("/set")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 527why, one step back527 def set_session():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 528–535why, one step back528 flask.session["test"] = "test"529 return ""530531 @app.route("/get")532 def get():533 return flask.session.get("test")534535 @app.route("/getitem")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 536why, one step back536 def getitem():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 537–539why, one step back537 return flask.session["test"]538539 @app.route("/setdefault")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 540why, one step back540 def setdefault():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 541–543why, one step back541 return flask.session.setdefault("test", "default")542543 @app.route("/vary-cookie-header-set")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 544why, one step back544 def vary_cookie_header_set():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 545–550why, one step back545 response = flask.Response()546 response.vary.add("Cookie")547 flask.session["test"] = "test"548 return response549550 @app.route("/vary-header-set")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 551why, one step back551 def vary_header_set():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 552–557why, one step back552 response = flask.Response()553 response.vary.update(("Accept-Encoding", "Accept-Language"))554 flask.session["test"] = "test"555 return response556557 @app.route("/no-vary-header")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 558why, one step back558 def no_vary_header():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 559–561why, one step back559 return ""560561 def expect(path, header_value="Cookie"):Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 562why, one step back562 rv = client.get(path)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 563why, one step back563Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 564–565why, one step back564 if header_value:565 # The 'Vary' key should exist in the headers only once.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 566–579why, one step back566 assert len(rv.headers.get_all("Vary")) == 1567 assert rv.headers["Vary"] == header_value568 else:569 assert "Vary" not in rv.headers570571 expect("/set")572 expect("/get")573 expect("/getitem")574 expect("/setdefault")575 expect("/vary-cookie-header-set")576 expect("/vary-header-set", "Accept-Encoding, Accept-Language, Cookie")577 expect("/no-vary-header", None)578579Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 580–581why, one step back580def test_flashes(app, req_ctx):581 assert not flask.session.modifiedMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 582why, one step back582 flask.flash("Zap")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 583why, one step back583 flask.session.modified = FalseMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 584why, one step back584 flask.flash("Zip")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 585why, one step back585 assert flask.session.modifiedMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 586–588why, one step back586 assert list(flask.get_flashed_messages()) == ["Zap", "Zip"]587588Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 589–594why, one step back589def test_extended_flashing(app):590 # Be sure app.testing=True below, else tests can fail silently.591 #592 # Specifically, if app.testing is not set to True, the AssertionErrors593 # in the view functions will cause a 500 response to the test client594 # instead of propagating exceptions.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 595–597why, one step back595596 @app.route("/")597 def index():Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
lines 598–600why, one step back598 flask.flash("Hello World")599 flask.flash("Hello World", "error")600 flask.flash(flask.Markup("<em>Testing</em>"), "warning")Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 601–604why, one step back601 return ""602603 @app.route("/test/")604 def test():Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 605why, one step back605 messages = flask.get_flashed_messages()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 606why, one step back606 assert list(messages) == [Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
lines 607–609why, one step back607 "Hello World",608 "Hello World",609 flask.Markup("<em>Testing</em>"),Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 610–613why, one step back610 ]611 return ""612613 @app.route("/test_with_categories/")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 614–616why, one step back614 def test_with_categories():615 messages = flask.get_flashed_messages(with_categories=True)616 assert len(messages) == 3Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 617why, one step back617 assert list(messages) == [Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
lines 618–620why, one step back618 ("message", "Hello World"),619 ("error", "Hello World"),620 ("warning", flask.Markup("<em>Testing</em>")),Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 621–624why, one step back621 ]622 return ""623624 @app.route("/test_filter/")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 625why, one step back625 def test_filter():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 626–628why, one step back626 messages = flask.get_flashed_messages(627 category_filter=["message"], with_categories=True628 )Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 629why, one step back629 assert list(messages) == [("message", "Hello World")]Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 630–632why, one step back630 return ""631632 @app.route("/test_filters/")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 633why, one step back633 def test_filters():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 634–637why, one step back634 messages = flask.get_flashed_messages(635 category_filter=["message", "warning"], with_categories=True636 )637 assert list(messages) == [Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
lines 638–639why, one step back638 ("message", "Hello World"),639 ("warning", flask.Markup("<em>Testing</em>")),Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 640–643why, one step back640 ]641 return ""642643 @app.route("/test_filters_without_returning_categories/")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 644why, one step back644 def test_filters2():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 645why, one step back645 messages = flask.get_flashed_messages(category_filter=["message", "warning"])Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 646why, one step back646 assert len(messages) == 2Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
lines 647–648why, one step back647 assert messages[0] == "Hello World"648 assert messages[1] == flask.Markup("<em>Testing</em>")Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 649–650why, one step back649 return ""650Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 651why, one step back651 # Create new test client on each test to clean flashed messages.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 652–669why, one step back652653 client = app.test_client()654 client.get("/")655 client.get("/test_with_categories/")656657 client = app.test_client()658 client.get("/")659 client.get("/test_filter/")660661 client = app.test_client()662 client.get("/")663 client.get("/test_filters/")664665 client = app.test_client()666 client.get("/")667 client.get("/test_filters_without_returning_categories/")668669Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 670why, one step back670def test_request_processing(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 671–694why, one step back671 evts = []672673 @app.before_request674 def before_request():675 evts.append("before")676677 @app.after_request678 def after_request(response):679 response.data += b"|after"680 evts.append("after")681 return response682683 @app.route("/")684 def index():685 assert "before" in evts686 assert "after" not in evts687 return "request"688689 assert "after" not in evts690 rv = client.get("/").data691 assert "after" in evts692 assert rv == b"request|after"693694Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 695why, one step back695def test_request_preprocessing_early_return(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 696–698why, one step back696 evts = []697698 @app.before_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 699–700why, one step back699 def before_request1():700 evts.append(1)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 701–702why, one step back701702 @app.before_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 703–705why, one step back703 def before_request2():704 evts.append(2)705 return "hello"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 706–707why, one step back706707 @app.before_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 708–710why, one step back708 def before_request3():709 evts.append(3)710 return "bye"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 711–714why, one step back711712 @app.route("/")713 def index():714 evts.append("index")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 715why, one step back715 return "damnit"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 716–718why, one step back716717 rv = client.get("/").data.strip()718 assert rv == b"hello"Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 719why, one step back719 assert evts == [1, 2]Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 720–721why, one step back720721Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 722why, one step back722def test_after_request_processing(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 723–724why, one step back723 @app.route("/")724 def index():Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 725–726why, one step back725 @flask.after_this_request726 def foo(response):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 727why, one step back727 response.headers["X-Foo"] = "a header"Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 728why, one step back728 return responseMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 729–732why, one step back729730 return "Test"731732 resp = client.get("/")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 733why, one step back733 assert resp.status_code == 200Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 734–736why, one step back734 assert resp.headers["X-Foo"] == "a header"735736Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 737why, one step back737def test_teardown_request_handler(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 738–754why, one step back738 called = []739740 @app.teardown_request741 def teardown_request(exc):742 called.append(True)743 return "Ignored"744745 @app.route("/")746 def root():747 return "Response"748749 rv = client.get("/")750 assert rv.status_code == 200751 assert b"Response" in rv.data752 assert len(called) == 1753754Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 755why, one step back755def test_teardown_request_handler_debug_mode(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 756–772why, one step back756 called = []757758 @app.teardown_request759 def teardown_request(exc):760 called.append(True)761 return "Ignored"762763 @app.route("/")764 def root():765 return "Response"766767 rv = client.get("/")768 assert rv.status_code == 200769 assert b"Response" in rv.data770 assert len(called) == 1771772Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 773why, one step back773def test_teardown_request_handler_error(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 774–777why, one step back774 called = []775 app.testing = False776777 @app.teardown_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 778why, one step back778 def teardown_request1(exc):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 779–785why, one step back779 assert type(exc) == ZeroDivisionError780 called.append(True)781 # This raises a new error and blows away sys.exc_info(), so we can782 # test that all teardown_requests get passed the same original783 # exception.784 try:785 raise TypeError()Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86
line 786why, one step back786 except Exception:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 787–789why, one step back787 pass788789 @app.teardown_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 790why, one step back790 def teardown_request2(exc):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 791–797why, one step back791 assert type(exc) == ZeroDivisionError792 called.append(True)793 # This raises a new error and blows away sys.exc_info(), so we can794 # test that all teardown_requests get passed the same original795 # exception.796 try:797 raise TypeError()Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86
line 798why, one step back798 except Exception:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 799–801why, one step back799 pass800801 @app.route("/")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 802why, one step back802 def fails():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 803–807why, one step back803 1 // 0804805 rv = client.get("/")806 assert rv.status_code == 500807 assert b"Internal Server Error" in rv.dataMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 808why, one step back808 assert len(called) == 2Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 809–810why, one step back809810Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 811why, one step back811def test_before_after_request_order(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 812–814why, one step back812 called = []813814 @app.before_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 815–816why, one step back815 def before1():816 called.append(1)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 817–818why, one step back817818 @app.before_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 819–820why, one step back819 def before2():820 called.append(2)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 821–822why, one step back821822 @app.after_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 823–824why, one step back823 def after1(response):824 called.append(4)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 825–827why, one step back825 return response826827 @app.after_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 828–829why, one step back828 def after2(response):829 called.append(3)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 830–832why, one step back830 return response831832 @app.teardown_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 833–834why, one step back833 def finish1(exc):834 called.append(6)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 835–836why, one step back835836 @app.teardown_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 837–838why, one step back837 def finish2(exc):838 called.append(5)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 839–845why, one step back839840 @app.route("/")841 def index():842 return "42"843844 rv = client.get("/")845 assert rv.data == b"42"Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 846why, one step back846 assert called == [1, 2, 3, 4, 5, 6]Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 847–848why, one step back847848Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 849why, one step back849def test_error_handling(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 850–852why, one step back850 app.testing = False851852 @app.errorhandler(404)Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 853why, one step back853 def not_found(e):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 854–859why, one step back854 return "not found", 404855856 @app.errorhandler(500)857 def internal_server_error(e):858 return "internal server error", 500859Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 860–861why, one step back860 @app.errorhandler(Forbidden)861 def forbidden(e):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 862–868why, one step back862 return "forbidden", 403863864 @app.route("/")865 def index():866 flask.abort(404)867868 @app.route("/error")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 869why, one step back869 def error():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 870–872why, one step back870 1 // 0871872 @app.route("/forbidden")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 873why, one step back873 def error2():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 874–882why, one step back874 flask.abort(403)875876 rv = client.get("/")877 assert rv.status_code == 404878 assert rv.data == b"not found"879 rv = client.get("/error")880 assert rv.status_code == 500881 assert b"internal server error" == rv.data882 rv = client.get("/forbidden")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 883why, one step back883 assert rv.status_code == 403Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 884–886why, one step back884 assert b"forbidden" == rv.data885886Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 887–888why, one step back887def test_error_handler_unknown_code(app):888 with pytest.raises(KeyError) as exc_info:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 889–893why, one step back889 app.register_error_handler(999, lambda e: ("999", 999))890891 assert "Use a subclass" in exc_info.value.args[0]892893Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 894why, one step back894def test_error_handling_processing(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 895–905why, one step back895 app.testing = False896897 @app.errorhandler(500)898 def internal_server_error(e):899 return "internal server error", 500900901 @app.route("/")902 def broken_func():903 1 // 0904905 @app.after_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 906why, one step back906 def after_request(resp):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 907why, one step back907 resp.mimetype = "text/x-special"Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 908why, one step back908 return respMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 909–914why, one step back909910 resp = client.get("/")911 assert resp.mimetype == "text/x-special"912 assert resp.data == b"internal server error"913914Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 915why, one step back915def test_baseexception_error_handling(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 916–919why, one step back916 app.testing = False917918 @app.route("/")919 def broken_func():Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 920why, one step back920 raise KeyboardInterrupt()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 921why, one step back921Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 922why, one step back922 with pytest.raises(KeyboardInterrupt):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 923–924why, one step back923 client.get("/")924Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 925–927why, one step back925 ctx = flask._request_ctx_stack.top926 assert ctx.preserved927 assert type(ctx._preserved_exc) is KeyboardInterruptMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 928–929why, one step back928929Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 930why, one step back930def test_before_request_and_routing_errors(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 931why, one step back931 @app.before_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 932why, one step back932 def attach_something():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 933–935why, one step back933 flask.g.something = "value"934935 @app.errorhandler(404)Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 936–937why, one step back936 def return_something(error):937 return flask.g.something, 404Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 938–943why, one step back938939 rv = client.get("/")940 assert rv.status_code == 404941 assert rv.data == b"value"942943Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 944–945why, one step back944def test_user_error_handling(app, client):945 class MyException(Exception):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 946–947why, one step back946 pass947Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 948–950why, one step back948 @app.errorhandler(MyException)949 def handle_my_exception(e):950 assert isinstance(e, MyException)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 951–954why, one step back951 return "42"952953 @app.route("/")954 def index():Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 955why, one step back955 raise MyException()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 956–959why, one step back956957 assert client.get("/").data == b"42"958959Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 960–961why, one step back960def test_http_error_subclass_handling(app, client):961 class ForbiddenSubclass(Forbidden):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 962–963why, one step back962 pass963Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 964why, one step back964 @app.errorhandler(ForbiddenSubclass)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 965why, one step back965 def handle_forbidden_subclass(e):Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 966why, one step back966 assert isinstance(e, ForbiddenSubclass)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 967–968why, one step back967 return "banana"968Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 969why, one step back969 @app.errorhandler(403)Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86
line 970why, one step back970 def handle_403(e):Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 971–972why, one step back971 assert not isinstance(e, ForbiddenSubclass)972 assert isinstance(e, Forbidden)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 973–975why, one step back973 return "apple"974975 @app.route("/1")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 976–977why, one step back976 def index1():977 raise ForbiddenSubclass()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 978–983why, one step back978979 @app.route("/2")980 def index2():981 flask.abort(403)982983 @app.route("/3")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 984–985why, one step back984 def index3():985 raise Forbidden()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 986–991why, one step back986987 assert client.get("/1").data == b"banana"988 assert client.get("/2").data == b"apple"989 assert client.get("/3").data == b"apple"990991Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 992–993why, one step back992def test_errorhandler_precedence(app, client):993 class E1(Exception):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 994–995why, one step back994 pass995Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 996why, one step back996 class E2(Exception):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 997–998why, one step back997 pass998Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 999why, one step back999 class E3(E1, E2):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1000–1001why, one step back1000 pass1001Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1002–1003why, one step back1002 @app.errorhandler(E2)1003 def handle_e2(e):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1004–1005why, one step back1004 return "E2"1005Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1006–1007why, one step back1006 @app.errorhandler(Exception)1007 def handle_exception(e):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1008–1010why, one step back1008 return "Exception"10091010 @app.route("/E1")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1011–1012why, one step back1011 def raise_e1():1012 raise E1Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1013–1014why, one step back10131014 @app.route("/E3")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1015–1016why, one step back1015 def raise_e3():1016 raise E3Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1017–1024why, one step back10171018 rv = client.get("/E1")1019 assert rv.data == b"Exception"10201021 rv = client.get("/E3")1022 assert rv.data == b"E2"10231024Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1025why, one step back1025def test_trapping_of_bad_request_key_errors(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1026–1030why, one step back1026 @app.route("/key")1027 def fail():1028 flask.request.form["missing_key"]10291030 @app.route("/abort")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1031–1032why, one step back1031 def allow_abort():1032 flask.abort(400)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1033–1040why, one step back10331034 rv = client.get("/key")1035 assert rv.status_code == 4001036 assert b"missing_key" not in rv.data1037 rv = client.get("/abort")1038 assert rv.status_code == 40010391040 app.debug = TrueMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1041why, one step back1041 with pytest.raises(KeyError) as e:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1042why, one step back1042 client.get("/key")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1043why, one step back1043 assert e.errisinstance(BadRequest)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1044–1049why, one step back1044 assert "missing_key" in e.value.get_description()1045 rv = client.get("/abort")1046 assert rv.status_code == 40010471048 app.debug = False1049 app.config["TRAP_BAD_REQUEST_ERRORS"] = TrueMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1050why, one step back1050 with pytest.raises(KeyError):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1051why, one step back1051 client.get("/key")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1052why, one step back1052 with pytest.raises(BadRequest):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1053–1055why, one step back1053 client.get("/abort")10541055Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1056why, one step back1056def test_trapping_of_all_http_exceptions(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1057–1062why, one step back1057 app.config["TRAP_HTTP_EXCEPTIONS"] = True10581059 @app.route("/fail")1060 def fail():1061 flask.abort(404)1062Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1063why, one step back1063 with pytest.raises(NotFound):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1064–1066why, one step back1064 client.get("/fail")10651066Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1067why, one step back1067def test_error_handler_after_processor_error(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1068–1071why, one step back1068 app.testing = False10691070 @app.before_request1071 def before_request():Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86
line 1072why, one step back1072 if _trigger == "before":Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1073–1076why, one step back1073 1 // 010741075 @app.after_request1076 def after_request(response):Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86
line 1077why, one step back1077 if _trigger == "after":Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1078–1088why, one step back1078 1 // 01079 return response10801081 @app.route("/")1082 def index():1083 return "Foo"10841085 @app.errorhandler(500)1086 def internal_server_error(e):1087 return "Hello Server Error", 5001088Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86
line 1089why, one step back1089 for _trigger in "before", "after":Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1090why, one step back1090 rv = client.get("/")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1091why, one step back1091 assert rv.status_code == 500Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1092–1094why, one step back1092 assert rv.data == b"Hello Server Error"10931094Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1095–1096why, one step back1095def test_enctype_debug_helper(app, client):1096 from flask.debughelpers import DebugFilesKeyErrorMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1097–1103why, one step back10971098 app.debug = True10991100 @app.route("/fail", methods=["POST"])1101 def index():1102 return flask.request.files["foo"].filename1103Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1104–1106why, one step back1104 # with statement is important because we leave an exception on the1105 # stack otherwise and we want to ensure that this is not the case1106 # to not negatively affect other tests.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1107why, one step back1107 with client:Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1108why, one step back1108 with pytest.raises(DebugFilesKeyError) as e:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1109–1110why, one step back1109 client.post("/fail", data={"foo": "index.txt"})1110 assert "no file contents were transmitted" in str(e.value)Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 1111why, one step back1111 assert "This was submitted: 'index.txt'" in str(e.value)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1112–1113why, one step back11121113Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1114why, one step back1114def test_response_types(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1115why, one step back1115 @app.route("/text")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1116why, one step back1116 def from_text():Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 1117why, one step back1117 return "Hällo Wörld"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1118–1119why, one step back11181119 @app.route("/bytes")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1120why, one step back1120 def from_bytes():Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 1121why, one step back1121 return "Hällo Wörld".encode()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1122–1123why, one step back11221123 @app.route("/full_tuple")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1124why, one step back1124 def from_full_tuple():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1125–1131why, one step back1125 return (1126 "Meh",1127 400,1128 {"X-Foo": "Testing", "Content-Type": "text/plain; charset=utf-8"},1129 )11301131 @app.route("/text_headers")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1132why, one step back1132 def from_text_headers():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1133–1135why, one step back1133 return "Hello", {"X-Foo": "Test", "Content-Type": "text/plain; charset=utf-8"}11341135 @app.route("/text_status")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1136why, one step back1136 def from_text_status():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1137–1139why, one step back1137 return "Hi, status!", 40011381139 @app.route("/response_headers")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1140why, one step back1140 def from_response_headers():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1141why, one step back1141 return (Merge pull request #3684 from MLH-Fellowship/3628-duplicate-headersDavid Lordbefore adoption2fa8eb3
lines 1142–1145why, one step back1142 flask.Response(1143 "Hello world", 404, {"Content-Type": "text/html", "X-Foo": "Baz"}1144 ),1145 {"Content-Type": "text/plain", "X-Foo": "Bar", "X-Bar": "Foo"},Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1146–1148why, one step back1146 )11471148 @app.route("/response_status")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1149why, one step back1149 def from_response_status():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1150–1152why, one step back1150 return app.response_class("Hello world", 400), 50011511152 @app.route("/wsgi")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1153–1154why, one step back1153 def from_wsgi():1154 return NotFound()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1155why, one step back1155Merge pull request #3229 from lordmauve/style-fixDavid Lordbefore adoption240e398
line 1156why, one step back1156 @app.route("/dict")Merge pull request #3111 from pgjones/masterDavid Lordbefore adoption855d59b
lines 1157–1158why, one step back1157 def from_dict():1158 return {"foo": "bar"}, 201Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1159why, one step back1159Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
lines 1160–1161why, one step back1160 assert client.get("/text").data == "Hällo Wörld".encode()1161 assert client.get("/bytes").data == "Hällo Wörld".encode()Merge pull request #3111 from pgjones/masterDavid Lordbefore adoption855d59b
line 1162why, one step back1162Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1163–1181why, one step back1163 rv = client.get("/full_tuple")1164 assert rv.data == b"Meh"1165 assert rv.headers["X-Foo"] == "Testing"1166 assert rv.status_code == 4001167 assert rv.mimetype == "text/plain"11681169 rv = client.get("/text_headers")1170 assert rv.data == b"Hello"1171 assert rv.headers["X-Foo"] == "Test"1172 assert rv.status_code == 2001173 assert rv.mimetype == "text/plain"11741175 rv = client.get("/text_status")1176 assert rv.data == b"Hi, status!"1177 assert rv.status_code == 4001178 assert rv.mimetype == "text/html"11791180 rv = client.get("/response_headers")1181 assert rv.data == b"Hello world"Merge pull request #3684 from MLH-Fellowship/3628-duplicate-headersDavid Lordbefore adoption2fa8eb3
lines 1182–1183why, one step back1182 assert rv.content_type == "text/plain"1183 assert rv.headers.getlist("X-Foo") == ["Bar"]Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1184–1193why, one step back1184 assert rv.headers["X-Bar"] == "Foo"1185 assert rv.status_code == 40411861187 rv = client.get("/response_status")1188 assert rv.data == b"Hello world"1189 assert rv.status_code == 50011901191 rv = client.get("/wsgi")1192 assert b"Not Found" in rv.data1193 assert rv.status_code == 404Merge pull request #3111 from pgjones/masterDavid Lordbefore adoption855d59b
line 1194why, one step back1194Merge pull request #3229 from lordmauve/style-fixDavid Lordbefore adoption240e398
line 1195why, one step back1195 rv = client.get("/dict")Merge pull request #3111 from pgjones/masterDavid Lordbefore adoption855d59b
lines 1196–1197why, one step back1196 assert rv.json == {"foo": "bar"}1197 assert rv.status_code == 201Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1198–1199why, one step back11981199Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1200why, one step back1200def test_response_type_errors():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1201–1204why, one step back1201 app = flask.Flask(__name__)1202 app.testing = True12031204 @app.route("/none")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1205why, one step back1205 def from_none():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1206–1208why, one step back1206 pass12071208 @app.route("/small_tuple")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1209why, one step back1209 def from_small_tuple():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1210–1212why, one step back1210 return ("Hello",)12111212 @app.route("/large_tuple")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1213why, one step back1213 def from_large_tuple():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1214–1216why, one step back1214 return "Hello", 234, {"X-Foo": "Bar"}, "???"12151216 @app.route("/bad_type")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1217–1218why, one step back1217 def from_bad_type():1218 return TrueMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1219–1220why, one step back12191220 @app.route("/bad_wsgi")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1221–1222why, one step back1221 def from_bad_wsgi():1222 return lambda: NoneMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1223–1227why, one step back12231224 c = app.test_client()12251226 with pytest.raises(TypeError) as e:1227 c.get("/none")Merge branch '1.0.x'David Lordbefore adoptionb05a685
line 1228why, one step back1228 assert "returned None" in str(e.value)Merge pull request #3498 from raymond-devries/3445-traceback-for-noneDavid Lordbefore adoptiona3e4395
line 1229why, one step back1229 assert "from_none" in str(e.value)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1230–1232why, one step back12301231 with pytest.raises(TypeError) as e:1232 c.get("/small_tuple")Merge branch '1.0.x'David Lordbefore adoptionb05a685
line 1233why, one step back1233 assert "tuple must have the form" in str(e.value)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1234–1238why, one step back12341235 pytest.raises(TypeError, c.get, "/large_tuple")12361237 with pytest.raises(TypeError) as e:1238 c.get("/bad_type")Merge branch '1.0.x'David Lordbefore adoptionb05a685
line 1239why, one step back1239 assert "it was a bool" in str(e.value)Merge pull request #3235 from johnzeringue/better-return-type-errorDavid Lordbefore adoption52f9aa7
line 1240why, one step back1240Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1241–1243why, one step back1241 pytest.raises(TypeError, c.get, "/bad_wsgi")12421243Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1244–1245why, one step back1244def test_make_response(app, req_ctx):1245 rv = flask.make_response()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1246–1260why, one step back1246 assert rv.status_code == 2001247 assert rv.data == b""1248 assert rv.mimetype == "text/html"12491250 rv = flask.make_response("Awesome")1251 assert rv.status_code == 2001252 assert rv.data == b"Awesome"1253 assert rv.mimetype == "text/html"12541255 rv = flask.make_response("W00t", 404)1256 assert rv.status_code == 4041257 assert rv.data == b"W00t"1258 assert rv.mimetype == "text/html"12591260Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1261why, one step back1261def test_make_response_with_response_instance(app, req_ctx):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1262–1263why, one step back1262 rv = flask.make_response(flask.jsonify({"msg": "W00t"}), 400)1263 assert rv.status_code == 400Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1264why, one step back1264 assert rv.data == b'{"msg":"W00t"}\n'Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1265–1281why, one step back1265 assert rv.mimetype == "application/json"12661267 rv = flask.make_response(flask.Response(""), 400)1268 assert rv.status_code == 4001269 assert rv.data == b""1270 assert rv.mimetype == "text/html"12711272 rv = flask.make_response(1273 flask.Response("", headers={"Content-Type": "text/html"}),1274 400,1275 [("X-Foo", "bar")],1276 )1277 assert rv.status_code == 4001278 assert rv.headers["Content-Type"] == "text/html"1279 assert rv.headers["X-Foo"] == "bar"12801281Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1282–1284why, one step back1282def test_jsonify_no_prettyprint(app, req_ctx):1283 app.config.update({"JSONIFY_PRETTYPRINT_REGULAR": False})1284 compressed_msg = b'{"msg":{"submsg":"W00t"},"msg2":"foobar"}\n'Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1285–1287why, one step back1285 uncompressed_msg = {"msg": {"submsg": "W00t"}, "msg2": "foobar"}12861287 rv = flask.make_response(flask.jsonify(uncompressed_msg), 200)Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1288why, one step back1288 assert rv.data == compressed_msgMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1289–1290why, one step back12891290Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1291–1293why, one step back1291def test_jsonify_prettyprint(app, req_ctx):1292 app.config.update({"JSONIFY_PRETTYPRINT_REGULAR": True})1293 compressed_msg = {"msg": {"submsg": "W00t"}, "msg2": "foobar"}Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1294why, one step back1294 pretty_response = (Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1295why, one step back1295 b'{\n "msg": {\n "submsg": "W00t"\n }, \n "msg2": "foobar"\n}\n'Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1296–1298why, one step back1296 )12971298 rv = flask.make_response(flask.jsonify(compressed_msg), 200)Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1299why, one step back1299 assert rv.data == pretty_responseMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1300–1301why, one step back13001301Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1302why, one step back1302def test_jsonify_mimetype(app, req_ctx):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1303–1307why, one step back1303 app.config.update({"JSONIFY_MIMETYPE": "application/vnd.api+json"})1304 msg = {"msg": {"submsg": "W00t"}}1305 rv = flask.make_response(flask.jsonify(msg), 200)1306 assert rv.mimetype == "application/vnd.api+json"1307Merge pull request #3195 from eruvanos/json_support_dataclassDavid Lordbefore adoptionb0185a6
lines 1308–1311why, one step back13081309@pytest.mark.skipif(sys.version_info < (3, 7), reason="requires Python >= 3.7")1310def test_json_dump_dataclass(app, req_ctx):1311 from dataclasses import make_dataclassMerge pull request #3229 from lordmauve/style-fixDavid Lordbefore adoption240e398
line 1312why, one step back1312Merge pull request #3195 from eruvanos/json_support_dataclassDavid Lordbefore adoptionb0185a6
lines 1313–1316why, one step back1313 Data = make_dataclass("Data", [("name", str)])1314 value = flask.json.dumps(Data("Flask"), app=app)1315 value = flask.json.loads(value, app=app)1316 assert value == {"name": "Flask"}Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1317why, one step back1317Merge pull request #3229 from lordmauve/style-fixDavid Lordbefore adoption240e398
line 1318why, one step back1318Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1319why, one step back1319def test_jsonify_args_and_kwargs_check(app, req_ctx):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1320–1324why, one step back1320 with pytest.raises(TypeError) as e:1321 flask.jsonify("fake args", kwargs="fake")1322 assert "behavior undefined" in str(e.value)13231324Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1325why, one step back1325def test_url_generation(app, req_ctx):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1326why, one step back1326 @app.route("/hello/<name>", methods=["POST"])Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1327why, one step back1327 def hello():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1328–1336why, one step back1328 pass13291330 assert flask.url_for("hello", name="test x") == "/hello/test%20x"1331 assert (1332 flask.url_for("hello", name="test x", _external=True)1333 == "http://localhost/hello/test%20x"1334 )13351336Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1337–1338why, one step back1337def test_build_error_handler(app):1338 # Test base case, a URL which results in a BuildError.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1339–1341why, one step back1339 with app.test_request_context():1340 pytest.raises(BuildError, flask.url_for, "spam")1341Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1342why, one step back1342 # Verify the error is re-raised if not the current exception.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1343why, one step back1343 try:Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1344why, one step back1344 with app.test_request_context():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1345why, one step back1345 flask.url_for("spam")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1346–1347why, one step back1346 except BuildError as err:1347 error = errMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1348–1349why, one step back1348 try:1349 raise RuntimeError("Test case where BuildError is not current.")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1350why, one step back1350 except RuntimeError:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1351–1352why, one step back1351 pytest.raises(BuildError, app.handle_url_build_error, error, "spam", {})1352Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1353why, one step back1353 # Test a custom handler.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1354why, one step back1354 def handler(error, endpoint, values):Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1355why, one step back1355 # Just a test.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1356–1357why, one step back1356 return "/test_handler/"1357Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1358why, one step back1358 app.url_build_error_handlers.append(handler)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1359–1362why, one step back1359 with app.test_request_context():1360 assert flask.url_for("spam") == "/test_handler/"13611362Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1363–1366why, one step back1363def test_build_error_handler_reraise(app):1364 # Test a custom handler which reraises the BuildError1365 def handler_raises_build_error(error, endpoint, values):1366 raise errorMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1367why, one step back1367Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1368why, one step back1368 app.url_build_error_handlers.append(handler_raises_build_error)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1369–1373why, one step back13691370 with app.test_request_context():1371 pytest.raises(BuildError, flask.url_for, "not.existing")13721373Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1374–1375why, one step back1374def test_url_for_passes_special_values_to_build_error_handler(app):1375 @app.url_build_error_handlers.appendMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1376why, one step back1376 def handler(error, endpoint, values):Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1377why, one step back1377 assert values == {Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1378–1388why, one step back1378 "_external": False,1379 "_anchor": None,1380 "_method": None,1381 "_scheme": None,1382 }1383 return "handled"13841385 with app.test_request_context():1386 flask.url_for("/")13871388Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1389why, one step back1389def test_static_files(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1390–1397why, one step back1390 rv = client.get("/static/index.html")1391 assert rv.status_code == 2001392 assert rv.data.strip() == b"<h1>Hello World!</h1>"1393 with app.test_request_context():1394 assert flask.url_for("static", filename="index.html") == "/static/index.html"1395 rv.close()13961397Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1398why, one step back1398def test_static_url_path():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1399–1408why, one step back1399 app = flask.Flask(__name__, static_url_path="/foo")1400 app.testing = True1401 rv = app.test_client().get("/foo/index.html")1402 assert rv.status_code == 2001403 rv.close()14041405 with app.test_request_context():1406 assert flask.url_for("static", filename="index.html") == "/foo/index.html"14071408Merge pull request #3182 from qil026/issue-3134-url-joinDavid Lordbefore adoptiondbd3840
lines 1409–1419why, one step back1409def test_static_url_path_with_ending_slash():1410 app = flask.Flask(__name__, static_url_path="/foo/")1411 app.testing = True1412 rv = app.test_client().get("/foo/index.html")1413 assert rv.status_code == 2001414 rv.close()14151416 with app.test_request_context():1417 assert flask.url_for("static", filename="index.html") == "/foo/index.html"14181419Merge pull request #3124 from elbeardmorez/fix_static_url_pathDavid Lordbefore adoption754b729
line 1420why, one step back1420def test_static_url_empty_path(app):Merge pull request #3229 from lordmauve/style-fixDavid Lordbefore adoption240e398
lines 1421–1422why, one step back1421 app = flask.Flask(__name__, static_folder="", static_url_path="")1422 rv = app.test_client().open("/static/index.html", method="GET")Merge pull request #3124 from elbeardmorez/fix_static_url_pathDavid Lordbefore adoption754b729
lines 1423–1427why, one step back1423 assert rv.status_code == 2001424 rv.close()142514261427def test_static_url_empty_path_default(app):Merge pull request #3229 from lordmauve/style-fixDavid Lordbefore adoption240e398
lines 1428–1429why, one step back1428 app = flask.Flask(__name__, static_folder="")1429 rv = app.test_client().open("/static/index.html", method="GET")Merge pull request #3124 from elbeardmorez/fix_static_url_pathDavid Lordbefore adoption754b729
lines 1430–1433why, one step back1430 assert rv.status_code == 2001431 rv.close()14321433Merge pull request #3579 from jab/pathlib-for-static_folderJoshua Bronsonbefore adoptioncf5b1d0
lines 1434–1443why, one step back1434@pytest.mark.skipif(sys.version_info < (3, 6), reason="requires Python >= 3.6")1435def test_static_folder_with_pathlib_path(app):1436 from pathlib import Path14371438 app = flask.Flask(__name__, static_folder=Path("static"))1439 rv = app.test_client().open("/static/index.html", method="GET")1440 assert rv.status_code == 2001441 rv.close()14421443Merge remote-tracking branch 'origin/1.1.x'David Lordbefore adoption64ba434
lines 1444–1454why, one step back1444def test_static_folder_with_ending_slash():1445 app = flask.Flask(__name__, static_folder="static/")14461447 @app.route("/<path:path>")1448 def catch_all(path):1449 return path14501451 rv = app.test_client().get("/catch/all")1452 assert rv.data == b"catch/all"14531454Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1455why, one step back1455def test_static_route_with_host_matching():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1456–1463why, one step back1456 app = flask.Flask(__name__, host_matching=True, static_host="example.com")1457 c = app.test_client()1458 rv = c.get("http://example.com/static/index.html")1459 assert rv.status_code == 2001460 rv.close()1461 with app.test_request_context():1462 rv = flask.url_for("static", filename="index.html", _external=True)1463 assert rv == "http://example.com/static/index.html"Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1464why, one step back1464 # Providing static_host without host_matching=True should error.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1465–1466why, one step back1465 with pytest.raises(Exception):1466 flask.Flask(__name__, static_host="example.com")Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86
lines 1467–1468why, one step back1467 # Providing host_matching=True with static_folder1468 # but without static_host should error.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1469why, one step back1469 with pytest.raises(Exception):Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1470why, one step back1470 flask.Flask(__name__, host_matching=True)Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86
lines 1471–1472why, one step back1471 # Providing host_matching=True without static_host1472 # but with static_folder=None should not error.Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1473why, one step back1473 flask.Flask(__name__, host_matching=True, static_folder=None)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1474–1475why, one step back14741475Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1476why, one step back1476def test_request_locals():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1477why, one step back1477 assert repr(flask.g) == "<LocalProxy unbound>"Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1478why, one step back1478 assert not flask.gMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1479–1480why, one step back14791480Merge branch '1.0.x'David Lordbefore adoption29111a3
line 1481why, one step back1481def test_server_name_subdomain():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1482–1486why, one step back1482 app = flask.Flask(__name__, subdomain_matching=True)1483 client = app.test_client()14841485 @app.route("/")1486 def index():Merge branch '1.0.x'David Lordbefore adoption29111a3
line 1487why, one step back1487 return "default"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1488–1489why, one step back14881489 @app.route("/", subdomain="foo")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1490why, one step back1490 def subdomain():Merge branch '1.0.x'David Lordbefore adoption29111a3
line 1491why, one step back1491 return "subdomain"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1492why, one step back1492Merge branch '1.0.x'David Lordbefore adoption29111a3
line 1493why, one step back1493 app.config["SERVER_NAME"] = "dev.local:5000"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1494why, one step back1494 rv = client.get("/")Merge branch '1.0.x'David Lordbefore adoption29111a3
line 1495why, one step back1495 assert rv.data == b"default"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1496why, one step back1496Merge branch '1.0.x'David Lordbefore adoption29111a3
lines 1497–1498why, one step back1497 rv = client.get("/", "http://dev.local:5000")1498 assert rv.data == b"default"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1499why, one step back1499Merge branch '1.0.x'David Lordbefore adoption29111a3
lines 1500–1501why, one step back1500 rv = client.get("/", "https://dev.local:5000")1501 assert rv.data == b"default"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1502why, one step back1502Merge branch '1.0.x'David Lordbefore adoption29111a3
lines 1503–1504why, one step back1503 app.config["SERVER_NAME"] = "dev.local:443"1504 rv = client.get("/", "https://dev.local")Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1505why, one step back1505Merge branch '1.0.x'David Lordbefore adoption29111a3
lines 1506–1508why, one step back1506 # Werkzeug 1.0 fixes matching https scheme with 443 port1507 if rv.status_code != 404:1508 assert rv.data == b"default"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1509why, one step back1509Merge branch '1.0.x'David Lordbefore adoption29111a3
lines 1510–1515why, one step back1510 app.config["SERVER_NAME"] = "dev.local"1511 rv = client.get("/", "https://dev.local")1512 assert rv.data == b"default"15131514 # suppress Werkzeug 1.0 warning about name mismatch1515 with pytest.warns(None):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1516–1518why, one step back1516 rv = client.get("/", "http://foo.localhost")1517 assert rv.status_code == 4041518Merge branch '1.0.x'David Lordbefore adoption29111a3
lines 1519–1520why, one step back1519 rv = client.get("/", "http://foo.dev.local")1520 assert rv.data == b"subdomain"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1521–1522why, one step back15211522Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1523–1524why, one step back1523def test_exception_propagation(app, client):1524 def apprunner(config_key):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1525–1528why, one step back1525 @app.route("/")1526 def index():1527 1 // 01528Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1529–1531why, one step back1529 if config_key is not None:1530 app.config[config_key] = True1531 with pytest.raises(Exception):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1532–1535why, one step back1532 client.get("/")1533 else:1534 assert client.get("/").status_code == 5001535Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1536–1539why, one step back1536 # we have to run this test in an isolated thread because if the1537 # debug flag is set to true and an exception happens the context is1538 # not torn down. This causes other tests that run after this fail1539 # when they expect no exception on the stack.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1540why, one step back1540 for config_key in "TESTING", "PROPAGATE_EXCEPTIONS", "DEBUG", None:Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1541–1543why, one step back1541 t = Thread(target=apprunner, args=(config_key,))1542 t.start()1543 t.join()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1544–1560why, one step back154415451546@pytest.mark.parametrize("debug", [True, False])1547@pytest.mark.parametrize("use_debugger", [True, False])1548@pytest.mark.parametrize("use_reloader", [True, False])1549@pytest.mark.parametrize("propagate_exceptions", [None, True, False])1550def test_werkzeug_passthrough_errors(1551 monkeypatch, debug, use_debugger, use_reloader, propagate_exceptions, app1552):1553 rv = {}15541555 # Mocks werkzeug.serving.run_simple method1556 def run_simple_mock(*args, **kwargs):1557 rv["passthrough_errors"] = kwargs.get("passthrough_errors")15581559 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)1560 app.config["PROPAGATE_EXCEPTIONS"] = propagate_exceptionsMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1561why, one step back1561 app.run(debug=debug, use_debugger=use_debugger, use_reloader=use_reloader)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1562–1563why, one step back15621563Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1564why, one step back1564def test_max_content_length(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1565–1567why, one step back1565 app.config["MAX_CONTENT_LENGTH"] = 6415661567 @app.before_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1568why, one step back1568 def always_first():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1569why, one step back1569 flask.request.form["myfile"]Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86
line 1570why, one step back1570 AssertionError()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1571–1572why, one step back15711572 @app.route("/accept", methods=["POST"])Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1573why, one step back1573 def accept_file():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1574why, one step back1574 flask.request.form["myfile"]Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86
line 1575why, one step back1575 AssertionError()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1576why, one step back1576Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1577–1578why, one step back1577 @app.errorhandler(413)1578 def catcher(error):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1579–1584why, one step back1579 return "42"15801581 rv = client.post("/accept", data={"myfile": "foo" * 100})1582 assert rv.data == b"42"15831584Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1585–1587why, one step back1585def test_url_processors(app, client):1586 @app.url_defaults1587 def add_language_code(endpoint, values):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1588–1592why, one step back1588 if flask.g.lang_code is not None and app.url_map.is_endpoint_expecting(1589 endpoint, "lang_code"1590 ):1591 values.setdefault("lang_code", flask.g.lang_code)1592Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1593–1594why, one step back1593 @app.url_value_preprocessor1594 def pull_lang_code(endpoint, values):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1595–1601why, one step back1595 flask.g.lang_code = values.pop("lang_code", None)15961597 @app.route("/<lang_code>/")1598 def index():1599 return flask.url_for("about")16001601 @app.route("/<lang_code>/about")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1602why, one step back1602 def about():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1603–1605why, one step back1603 return flask.url_for("something_else")16041605 @app.route("/foo")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1606why, one step back1606 def something_else():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1607–1613why, one step back1607 return flask.url_for("about", lang_code="en")16081609 assert client.get("/de/").data == b"/de/about"1610 assert client.get("/de/about").data == b"/foo"1611 assert client.get("/foo").data == b"/en/about"16121613Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1614why, one step back1614def test_inject_blueprint_url_defaults(app):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1615–1616why, one step back1615 bp = flask.Blueprint("foo.bar.baz", __name__, template_folder="template")1616Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1617–1618why, one step back1617 @bp.url_defaults1618 def bp_defaults(endpoint, values):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1619–1621why, one step back1619 values["page"] = "login"16201621 @bp.route("/<page>")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1622why, one step back1622 def view(page):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1623–1624why, one step back1623 pass1624Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1625why, one step back1625 app.register_blueprint(bp)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1626why, one step back1626Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1627why, one step back1627 values = dict()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1628–1629why, one step back1628 app.inject_url_defaults("foo.bar.baz.view", values)1629 expected = dict(page="login")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1630why, one step back1630 assert values == expectedMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1631–1634why, one step back16311632 with app.test_request_context("/somepage"):1633 url = flask.url_for("foo.bar.baz.view")1634 expected = "/login"Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1635why, one step back1635 assert url == expectedMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1636–1637why, one step back16361637Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1638why, one step back1638def test_nonascii_pathinfo(app, client):Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 1639why, one step back1639 @app.route("/киртест")Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1640–1642why, one step back1640 def index():1641 return "Hello World!"1642Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 1643why, one step back1643 rv = client.get("/киртест")Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1644–1646why, one step back1644 assert rv.data == b"Hello World!"16451646Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1647why, one step back1647def test_debug_mode_complains_after_first_request(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1648–1653why, one step back1648 app.debug = True16491650 @app.route("/")1651 def index():1652 return "Awesome"1653Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1654why, one step back1654 assert not app.got_first_requestMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1655why, one step back1655 assert client.get("/").data == b"Awesome"Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1656why, one step back1656 with pytest.raises(AssertionError) as e:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1657–1658why, one step back16571658 @app.route("/foo")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1659why, one step back1659 def broken():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1660–1661why, one step back1660 return "Meh"1661Merge branch '1.0.x'David Lordbefore adoptionb05a685
line 1662why, one step back1662 assert "A setup function was called" in str(e.value)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1663–1666why, one step back16631664 app.debug = False16651666 @app.route("/foo")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1667why, one step back1667 def working():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1668–1673why, one step back1668 return "Meh"16691670 assert client.get("/foo").data == b"Meh"1671 assert app.got_first_request16721673Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1674why, one step back1674def test_before_first_request_functions(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1675–1687why, one step back1675 got = []16761677 @app.before_first_request1678 def foo():1679 got.append(42)16801681 client.get("/")1682 assert got == [42]1683 client.get("/")1684 assert got == [42]1685 assert app.got_first_request16861687Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1688why, one step back1688def test_before_first_request_functions_concurrent(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1689–1692why, one step back1689 got = []16901691 @app.before_first_request1692 def foo():Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1693why, one step back1693 time.sleep(0.2)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1694–1695why, one step back1694 got.append(42)1695Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1696why, one step back1696 def get_and_assert():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1697why, one step back1697 client.get("/")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1698why, one step back1698 assert got == [42]Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1699why, one step back1699Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1700–1703why, one step back1700 t = Thread(target=get_and_assert)1701 t.start()1702 get_and_assert()1703 t.join()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1704–1706why, one step back1704 assert app.got_first_request17051706Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1707why, one step back1707def test_routing_redirect_debugging(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1708–1714why, one step back1708 app.debug = True17091710 @app.route("/foo/", methods=["GET", "POST"])1711 def foo():1712 return "success"17131714 with client:Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1715why, one step back1715 with pytest.raises(AssertionError) as e:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1716why, one step back1716 client.post("/foo", data={})Merge branch '1.0.x'David Lordbefore adoptionb05a685
line 1717why, one step back1717 assert "http://localhost/foo/" in str(e.value)Merge pull request #3453 from noviluni/remove_redundant_parenthesesDavid Lordbefore adoption986871b
line 1718why, one step back1718 assert "Make sure to directly send your POST-request to this URL" in str(Merge branch '1.0.x'David Lordbefore adoptionb05a685
lines 1719–1720why, one step back1719 e.value1720 )Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1721–1730why, one step back17211722 rv = client.get("/foo", data={}, follow_redirects=True)1723 assert rv.data == b"success"17241725 app.debug = False1726 with client:1727 rv = client.post("/foo", data={}, follow_redirects=True)1728 assert rv.data == b"success"17291730Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1731why, one step back1731def test_route_decorator_custom_endpoint(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1732–1738why, one step back1732 app.debug = True17331734 @app.route("/foo/")1735 def foo():1736 return flask.request.endpoint17371738 @app.route("/bar/", endpoint="bar")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1739why, one step back1739 def for_bar():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1740–1742why, one step back1740 return flask.request.endpoint17411742 @app.route("/bar/123", endpoint="123")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1743why, one step back1743 def for_bar_foo():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1744–1755why, one step back1744 return flask.request.endpoint17451746 with app.test_request_context():1747 assert flask.url_for("foo") == "/foo/"1748 assert flask.url_for("bar") == "/bar/"1749 assert flask.url_for("123") == "/bar/123"17501751 assert client.get("/foo/").data == b"foo"1752 assert client.get("/bar/").data == b"bar"1753 assert client.get("/bar/123").data == b"123"17541755Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1756why, one step back1756def test_preserve_only_once(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1757–1762why, one step back1757 app.debug = True17581759 @app.route("/fail")1760 def fail_func():1761 1 // 01762Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86
line 1763why, one step back1763 for _x in range(3):Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1764why, one step back1764 with pytest.raises(ZeroDivisionError):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1765–1766why, one step back1765 client.get("/fail")1766Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1767–1772why, one step back1767 assert flask._request_ctx_stack.top is not None1768 assert flask._app_ctx_stack.top is not None1769 # implicit appctx disappears too1770 flask._request_ctx_stack.top.pop()1771 assert flask._request_ctx_stack.top is None1772 assert flask._app_ctx_stack.top is NoneMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1773–1774why, one step back17731774Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1775why, one step back1775def test_preserve_remembers_exception(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1776why, one step back1776 app.debug = TrueMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1777why, one step back1777 errors = []Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1778–1783why, one step back17781779 @app.route("/fail")1780 def fail_func():1781 1 // 017821783 @app.route("/success")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1784why, one step back1784 def success_func():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1785–1787why, one step back1785 return "Okay"17861787 @app.teardown_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1788–1789why, one step back1788 def teardown_handler(exc):1789 errors.append(exc)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1790why, one step back1790Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1791–1792why, one step back1791 # After this failure we did not yet call the teardown handler1792 with pytest.raises(ZeroDivisionError):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1793why, one step back1793 client.get("/fail")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1794why, one step back1794 assert errors == []Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1795why, one step back1795Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1796why, one step back1796 # But this request triggers it, and it's an errorMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1797why, one step back1797 client.get("/success")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1798–1799why, one step back1798 assert len(errors) == 21799 assert isinstance(errors[0], ZeroDivisionError)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1800why, one step back1800Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1801why, one step back1801 # At this point another request does nothing.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1802why, one step back1802 client.get("/success")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1803–1804why, one step back1803 assert len(errors) == 31804 assert errors[1] is NoneMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1805–1806why, one step back18051806Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1807why, one step back1807def test_get_method_on_g(app_ctx):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1808–1809why, one step back1808 assert flask.g.get("x") is None1809 assert flask.g.get("x", 11) == 11Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1810why, one step back1810 flask.g.x = 42Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1811why, one step back1811 assert flask.g.get("x") == 42Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1812why, one step back1812 assert flask.g.x == 42Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1813–1814why, one step back18131814Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1815–1817why, one step back1815def test_g_iteration_protocol(app_ctx):1816 flask.g.foo = 231817 flask.g.bar = 42Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1818–1822why, one step back1818 assert "foo" in flask.g1819 assert "foos" not in flask.g1820 assert sorted(flask.g) == ["bar", "foo"]18211822Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1823why, one step back1823def test_subdomain_basic_support():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1824–1828why, one step back1824 app = flask.Flask(__name__, subdomain_matching=True)1825 app.config["SERVER_NAME"] = "localhost.localdomain"1826 client = app.test_client()18271828 @app.route("/")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1829why, one step back1829 def normal_index():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1830–1832why, one step back1830 return "normal index"18311832 @app.route("/", subdomain="test")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1833why, one step back1833 def test_index():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1834–1842why, one step back1834 return "test index"18351836 rv = client.get("/", "http://localhost.localdomain/")1837 assert rv.data == b"normal index"18381839 rv = client.get("/", "http://test.localhost.localdomain/")1840 assert rv.data == b"test index"18411842Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1843why, one step back1843def test_subdomain_matching():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1844–1849why, one step back1844 app = flask.Flask(__name__, subdomain_matching=True)1845 client = app.test_client()1846 app.config["SERVER_NAME"] = "localhost.localdomain"18471848 @app.route("/", subdomain="<user>")1849 def index(user):Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 1850why, one step back1850 return f"index for {user}"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1851–1855why, one step back18511852 rv = client.get("/", "http://mitsuhiko.localhost.localdomain/")1853 assert rv.data == b"index for mitsuhiko"18541855Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1856why, one step back1856def test_subdomain_matching_with_ports():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1857–1862why, one step back1857 app = flask.Flask(__name__, subdomain_matching=True)1858 app.config["SERVER_NAME"] = "localhost.localdomain:3000"1859 client = app.test_client()18601861 @app.route("/", subdomain="<user>")1862 def index(user):Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 1863why, one step back1863 return f"index for {user}"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1864–1869why, one step back18641865 rv = client.get("/", "http://mitsuhiko.localhost.localdomain:3000/")1866 assert rv.data == b"index for mitsuhiko"186718681869@pytest.mark.parametrize("matching", (False, True))Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1870–1871why, one step back1870def test_subdomain_matching_other_name(matching):1871 app = flask.Flask(__name__, subdomain_matching=matching)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1872–1878why, one step back1872 app.config["SERVER_NAME"] = "localhost.localdomain:3000"1873 client = app.test_client()18741875 @app.route("/")1876 def index():1877 return "", 2041878Merge branch '1.0.x'David Lordbefore adoption29111a3
lines 1879–1883why, one step back1879 # suppress Werkzeug 0.15 warning about name mismatch1880 with pytest.warns(None):1881 # ip address can't match name1882 rv = client.get("/", "http://127.0.0.1:3000/")1883 assert rv.status_code == 404 if matching else 204Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1884why, one step back1884Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1885why, one step back1885 # allow all subdomains if matching is disabledMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1886–1889why, one step back1886 rv = client.get("/", "http://www.localhost.localdomain:3000/")1887 assert rv.status_code == 404 if matching else 20418881889Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1890why, one step back1890def test_multi_route_rules(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1891–1893why, one step back1891 @app.route("/")1892 @app.route("/<test>/")1893 def index(test="a"):Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1894why, one step back1894 return testMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1895–1901why, one step back18951896 rv = client.open("/")1897 assert rv.data == b"a"1898 rv = client.open("/b/")1899 assert rv.data == b"b"19001901Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1902why, one step back1902def test_multi_route_class_views(app, client):Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 1903why, one step back1903 class View:Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1904why, one step back1904 def __init__(self, app):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1905–1908why, one step back1905 app.add_url_rule("/", "index", self.index)1906 app.add_url_rule("/<test>/", "index", self.index)19071908 def index(self, test="a"):Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1909why, one step back1909 return testMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1910why, one step back1910Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1911why, one step back1911 _ = View(app)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1912–1917why, one step back1912 rv = client.open("/")1913 assert rv.data == b"a"1914 rv = client.open("/b/")1915 assert rv.data == b"b"19161917Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1918why, one step back1918def test_run_defaults(monkeypatch, app):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1919–1925why, one step back1919 rv = {}19201921 # Mocks werkzeug.serving.run_simple method1922 def run_simple_mock(*args, **kwargs):1923 rv["result"] = "running..."19241925 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1926why, one step back1926 app.run()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1927–1929why, one step back1927 assert rv["result"] == "running..."19281929Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1930why, one step back1930def test_run_server_port(monkeypatch, app):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1931–1933why, one step back1931 rv = {}19321933 # Mocks werkzeug.serving.run_simple methodMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1934why, one step back1934 def run_simple_mock(hostname, port, application, *args, **kwargs):Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 1935why, one step back1935 rv["result"] = f"running on {hostname}:{port} ..."Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1936–1938why, one step back19361937 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)1938 hostname, port = "localhost", 8000Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1939why, one step back1939 app.run(hostname, port, debug=True)Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 1940why, one step back1940 assert rv["result"] == f"running on {hostname}:{port} ..."Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1941–1943why, one step back194119421943@pytest.mark.parametrize(Merge pull request #2928 from vorelq/2926-default-port-overrides-zeroDavid Lordbefore adoptiond9fa28b
line 1944why, one step back1944 "host,port,server_name,expect_host,expect_port",Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1945why, one step back1945 (Merge pull request #2928 from vorelq/2926-default-port-overrides-zeroDavid Lordbefore adoptiond9fa28b
lines 1946–1952why, one step back1946 (None, None, "pocoo.org:8080", "pocoo.org", 8080),1947 ("localhost", None, "pocoo.org:8080", "localhost", 8080),1948 (None, 80, "pocoo.org:8080", "pocoo.org", 80),1949 ("localhost", 80, "pocoo.org:8080", "localhost", 80),1950 ("localhost", 0, "localhost:8080", "localhost", 0),1951 (None, None, "localhost:8080", "localhost", 8080),1952 (None, None, "localhost:0", "localhost", 0),Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1953–1954why, one step back1953 ),1954)Merge pull request #3229 from lordmauve/style-fixDavid Lordbefore adoption240e398
lines 1955–1957why, one step back1955def test_run_from_config(1956 monkeypatch, host, port, server_name, expect_host, expect_port, app1957):Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1958–1960why, one step back1958 def run_simple_mock(hostname, port, *args, **kwargs):1959 assert hostname == expect_host1960 assert port == expect_portMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1961–1962why, one step back19611962 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)Merge pull request #2928 from vorelq/2926-default-port-overrides-zeroDavid Lordbefore adoptiond9fa28b
line 1963why, one step back1963 app.config["SERVER_NAME"] = server_nameMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1964why, one step back1964 app.run(host, port)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1965–1966why, one step back19651966Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1967why, one step back1967def test_max_cookie_size(app, client, recwarn):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1968–1969why, one step back1968 app.config["MAX_COOKIE_SIZE"] = 1001969Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1970–1972why, one step back1970 # outside app context, default to Werkzeug static value,1971 # which is also the default config1972 response = flask.Response()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1973why, one step back1973 default = flask.Flask.default_config["MAX_COOKIE_SIZE"]Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1974why, one step back1974 assert response.max_cookie_size == defaultMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1975why, one step back1975Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1976–1978why, one step back1976 # inside app context, use app config1977 with app.app_context():1978 assert flask.Response().max_cookie_size == 100Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1979–1983why, one step back19791980 @app.route("/")1981 def index():1982 r = flask.Response("", status=204)1983 r.set_cookie("foo", "bar" * 100)Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1984why, one step back1984 return rMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1985–1986why, one step back19851986 client.get("/")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1987–1988why, one step back1987 assert len(recwarn) == 11988 w = recwarn.pop()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1989–1993why, one step back1989 assert "cookie is too large" in str(w.message)19901991 app.config["MAX_COOKIE_SIZE"] = 019921993 client.get("/")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1994why, one step back1994 assert len(recwarn) == 0Break reference cycle created by default in Flask instances.Bogdan Opanchukbefore adoption8efea0c
lines 1995–2010why, one step back199519961997@require_cpython_gc1998def test_app_freed_on_zero_refcount():1999 # A Flask instance should not create a reference cycle that prevents CPython2000 # from freeing it when all external references to it are released (see #3761).The first 2,000 of 2,010 lines.