test_basic.py
This file
Path
tests/test_basic.py
1,997 lines · 53.6 KiB · Python
Last changed by
update requirements (#3823)David Lordbefore adoption373f0dd
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–325why, 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 cookie324325Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 326why, one step back326def test_session_using_samesite_attribute(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 327–333why, one step back327 @app.route("/")328 def index():329 flask.session["testing"] = 42330 return "Hello World"331332 app.config.update(SESSION_COOKIE_SAMESITE="invalid")333Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 334why, one step back334 with pytest.raises(ValueError):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 335–336why, one step back335 client.get("/")336Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 337why, one step back337 app.config.update(SESSION_COOKIE_SAMESITE=None)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 338–352why, one step back338 rv = client.get("/")339 cookie = rv.headers["set-cookie"].lower()340 assert "samesite" not in cookie341342 app.config.update(SESSION_COOKIE_SAMESITE="Strict")343 rv = client.get("/")344 cookie = rv.headers["set-cookie"].lower()345 assert "samesite=strict" in cookie346347 app.config.update(SESSION_COOKIE_SAMESITE="Lax")348 rv = client.get("/")349 cookie = rv.headers["set-cookie"].lower()350 assert "samesite=lax" in cookie351352Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 353why, one step back353def test_session_localhost_warning(recwarn, app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 354–363why, one step back354 app.config.update(SERVER_NAME="localhost:5000")355356 @app.route("/")357 def index():358 flask.session["testing"] = 42359 return "testing"360361 rv = client.get("/", "http://localhost:5000/")362 assert "domain" not in rv.headers["set-cookie"].lower()363 w = recwarn.pop(UserWarning)Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 364why, one step back364 assert "'localhost' is not a valid cookie domain" in str(w.message)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 365–366why, one step back365366Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 367why, one step back367def test_session_ip_warning(recwarn, app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 368–380why, one step back368 app.config.update(SERVER_NAME="127.0.0.1:5000")369370 @app.route("/")371 def index():372 flask.session["testing"] = 42373 return "testing"374375 rv = client.get("/", "http://127.0.0.1:5000/")376 assert "domain=127.0.0.1" in rv.headers["set-cookie"].lower()377 w = recwarn.pop(UserWarning)378 assert "cookie domain is an IP" in str(w.message)379380Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 381–382why, one step back381def test_missing_session(app):382 app.secret_key = NoneMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 383why, one step back383Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 384–385why, one step back384 def expect_exception(f, *args, **kwargs):385 e = pytest.raises(RuntimeError, f, *args, **kwargs)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 386–393why, one step back386 assert e.value.args and "session is unavailable" in e.value.args[0]387388 with app.test_request_context():389 assert flask.session.get("missing_key") is None390 expect_exception(flask.session.__setitem__, "foo", 42)391 expect_exception(flask.session.pop, "foo")392393Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 394–395why, one step back394def test_session_expiration(app, client):395 permanent = TrueMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 396–399why, one step back396397 @app.route("/")398 def index():399 flask.session["test"] = 42Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 400why, one step back400 flask.session.permanent = permanentMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 401–404why, one step back401 return ""402403 @app.route("/test")404 def test():Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 405why, one step back405 return str(flask.session.permanent)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 406–409why, one step back406407 rv = client.get("/")408 assert "set-cookie" in rv.headers409 match = re.search(r"(?i)\bexpires=([^;]+)", rv.headers["set-cookie"])Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 410–414why, one step back410 expires = parse_date(match.group())411 expected = datetime.utcnow() + app.permanent_session_lifetime412 assert expires.year == expected.year413 assert expires.month == expected.month414 assert expires.day == expected.dayMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 415–418why, one step back415416 rv = client.get("/test")417 assert rv.data == b"True"418Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 419why, one step back419 permanent = FalseMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 420–422why, one step back420 rv = client.get("/")421 assert "set-cookie" in rv.headers422 match = re.search(r"\bexpires=([^;]+)", rv.headers["set-cookie"])Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 423why, one step back423 assert match is NoneMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 424–425why, one step back424425Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 426why, one step back426def test_session_stored_last(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 427why, one step back427 @app.after_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 428why, one step back428 def modify_session(response):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 429–439why, one step back429 flask.session["foo"] = 42430 return response431432 @app.route("/")433 def dump_session_contents():434 return repr(flask.session.get("foo"))435436 assert client.get("/").data == b"None"437 assert client.get("/").data == b"42"438439Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 440–442why, one step back440def test_session_special_types(app, client):441 now = datetime.utcnow().replace(microsecond=0)442 the_uuid = uuid.uuid4()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 443–457why, one step back443444 @app.route("/")445 def dump_session_contents():446 flask.session["t"] = (1, 2, 3)447 flask.session["b"] = b"\xff"448 flask.session["m"] = flask.Markup("<html>")449 flask.session["u"] = the_uuid450 flask.session["d"] = now451 flask.session["t_tag"] = {" t": "not-a-tuple"}452 flask.session["di_t_tag"] = {" t__": "not-a-tuple"}453 flask.session["di_tag"] = {" di": "not-a-dict"}454 return "", 204455456 with client:457 client.get("/")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 458why, one step back458 s = flask.sessionMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 459–470why, one step back459 assert s["t"] == (1, 2, 3)460 assert type(s["b"]) == bytes461 assert s["b"] == b"\xff"462 assert type(s["m"]) == flask.Markup463 assert s["m"] == flask.Markup("<html>")464 assert s["u"] == the_uuid465 assert s["d"] == now466 assert s["t_tag"] == {" t": "not-a-tuple"}467 assert s["di_t_tag"] == {" t__": "not-a-tuple"}468 assert s["di_tag"] == {" di": "not-a-dict"}469470Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 471why, one step back471def test_session_cookie_setting(app):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 472–474why, one step back472 is_permanent = True473474 @app.route("/bump")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 475why, one step back475 def bump():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 476why, one step back476 rv = flask.session["foo"] = flask.session.get("foo", 0) + 1Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 477–478why, one step back477 flask.session.permanent = is_permanent478 return str(rv)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 479–480why, one step back479480 @app.route("/read")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 481why, one step back481 def read():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 482–483why, one step back482 return str(flask.session.get("foo", 0))483Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 484–485why, one step back484 def run_test(expect_header):485 with app.test_client() as c:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 486–491why, one step back486 assert c.get("/bump").data == b"1"487 assert c.get("/bump").data == b"2"488 assert c.get("/bump").data == b"3"489490 rv = c.get("/read")491 set_cookie = rv.headers.get("set-cookie")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 492why, one step back492 assert (set_cookie is not None) == expect_headerMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 493–496why, one step back493 assert rv.data == b"3"494495 is_permanent = True496 app.config["SESSION_REFRESH_EACH_REQUEST"] = TrueMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 497why, one step back497 run_test(expect_header=True)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 498–511why, one step back498499 is_permanent = True500 app.config["SESSION_REFRESH_EACH_REQUEST"] = False501 run_test(expect_header=False)502503 is_permanent = False504 app.config["SESSION_REFRESH_EACH_REQUEST"] = True505 run_test(expect_header=False)506507 is_permanent = False508 app.config["SESSION_REFRESH_EACH_REQUEST"] = False509 run_test(expect_header=False)510511Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 512why, one step back512def test_session_vary_cookie(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 513why, one step back513 @app.route("/set")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 514why, one step back514 def set_session():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 515–522why, one step back515 flask.session["test"] = "test"516 return ""517518 @app.route("/get")519 def get():520 return flask.session.get("test")521522 @app.route("/getitem")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 523why, one step back523 def getitem():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 524–526why, one step back524 return flask.session["test"]525526 @app.route("/setdefault")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 527why, one step back527 def setdefault():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 528–530why, one step back528 return flask.session.setdefault("test", "default")529530 @app.route("/vary-cookie-header-set")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 531why, one step back531 def vary_cookie_header_set():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 532–537why, one step back532 response = flask.Response()533 response.vary.add("Cookie")534 flask.session["test"] = "test"535 return response536537 @app.route("/vary-header-set")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 538why, one step back538 def vary_header_set():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 539–544why, one step back539 response = flask.Response()540 response.vary.update(("Accept-Encoding", "Accept-Language"))541 flask.session["test"] = "test"542 return response543544 @app.route("/no-vary-header")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 545why, one step back545 def no_vary_header():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 546–548why, one step back546 return ""547548 def expect(path, header_value="Cookie"):Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 549why, one step back549 rv = client.get(path)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 550why, one step back550Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 551–552why, one step back551 if header_value:552 # The 'Vary' key should exist in the headers only once.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 553–566why, one step back553 assert len(rv.headers.get_all("Vary")) == 1554 assert rv.headers["Vary"] == header_value555 else:556 assert "Vary" not in rv.headers557558 expect("/set")559 expect("/get")560 expect("/getitem")561 expect("/setdefault")562 expect("/vary-cookie-header-set")563 expect("/vary-header-set", "Accept-Encoding, Accept-Language, Cookie")564 expect("/no-vary-header", None)565566Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 567–568why, one step back567def test_flashes(app, req_ctx):568 assert not flask.session.modifiedMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 569why, one step back569 flask.flash("Zap")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 570why, one step back570 flask.session.modified = FalseMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 571why, one step back571 flask.flash("Zip")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 572why, one step back572 assert flask.session.modifiedMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 573–575why, one step back573 assert list(flask.get_flashed_messages()) == ["Zap", "Zip"]574575Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 576–581why, one step back576def test_extended_flashing(app):577 # Be sure app.testing=True below, else tests can fail silently.578 #579 # Specifically, if app.testing is not set to True, the AssertionErrors580 # in the view functions will cause a 500 response to the test client581 # instead of propagating exceptions.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 582–584why, one step back582583 @app.route("/")584 def index():Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
lines 585–587why, one step back585 flask.flash("Hello World")586 flask.flash("Hello World", "error")587 flask.flash(flask.Markup("<em>Testing</em>"), "warning")Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 588–591why, one step back588 return ""589590 @app.route("/test/")591 def test():Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 592why, one step back592 messages = flask.get_flashed_messages()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 593why, one step back593 assert list(messages) == [Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
lines 594–596why, one step back594 "Hello World",595 "Hello World",596 flask.Markup("<em>Testing</em>"),Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 597–600why, one step back597 ]598 return ""599600 @app.route("/test_with_categories/")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 601–603why, one step back601 def test_with_categories():602 messages = flask.get_flashed_messages(with_categories=True)603 assert len(messages) == 3Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 604why, one step back604 assert list(messages) == [Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
lines 605–607why, one step back605 ("message", "Hello World"),606 ("error", "Hello World"),607 ("warning", flask.Markup("<em>Testing</em>")),Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 608–611why, one step back608 ]609 return ""610611 @app.route("/test_filter/")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 612why, one step back612 def test_filter():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 613–615why, one step back613 messages = flask.get_flashed_messages(614 category_filter=["message"], with_categories=True615 )Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 616why, one step back616 assert list(messages) == [("message", "Hello World")]Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 617–619why, one step back617 return ""618619 @app.route("/test_filters/")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 620why, one step back620 def test_filters():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 621–624why, one step back621 messages = flask.get_flashed_messages(622 category_filter=["message", "warning"], with_categories=True623 )624 assert list(messages) == [Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
lines 625–626why, one step back625 ("message", "Hello World"),626 ("warning", flask.Markup("<em>Testing</em>")),Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 627–630why, one step back627 ]628 return ""629630 @app.route("/test_filters_without_returning_categories/")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 631why, one step back631 def test_filters2():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 632why, one step back632 messages = flask.get_flashed_messages(category_filter=["message", "warning"])Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 633why, one step back633 assert len(messages) == 2Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
lines 634–635why, one step back634 assert messages[0] == "Hello World"635 assert messages[1] == flask.Markup("<em>Testing</em>")Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 636–637why, one step back636 return ""637Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 638why, one step back638 # Create new test client on each test to clean flashed messages.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 639–656why, one step back639640 client = app.test_client()641 client.get("/")642 client.get("/test_with_categories/")643644 client = app.test_client()645 client.get("/")646 client.get("/test_filter/")647648 client = app.test_client()649 client.get("/")650 client.get("/test_filters/")651652 client = app.test_client()653 client.get("/")654 client.get("/test_filters_without_returning_categories/")655656Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 657why, one step back657def test_request_processing(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 658–681why, one step back658 evts = []659660 @app.before_request661 def before_request():662 evts.append("before")663664 @app.after_request665 def after_request(response):666 response.data += b"|after"667 evts.append("after")668 return response669670 @app.route("/")671 def index():672 assert "before" in evts673 assert "after" not in evts674 return "request"675676 assert "after" not in evts677 rv = client.get("/").data678 assert "after" in evts679 assert rv == b"request|after"680681Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 682why, one step back682def test_request_preprocessing_early_return(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 683–685why, one step back683 evts = []684685 @app.before_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 686–687why, one step back686 def before_request1():687 evts.append(1)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 688–689why, one step back688689 @app.before_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 690–692why, one step back690 def before_request2():691 evts.append(2)692 return "hello"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 693–694why, one step back693694 @app.before_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 695–697why, one step back695 def before_request3():696 evts.append(3)697 return "bye"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 698–701why, one step back698699 @app.route("/")700 def index():701 evts.append("index")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 702why, one step back702 return "damnit"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 703–705why, one step back703704 rv = client.get("/").data.strip()705 assert rv == b"hello"Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 706why, one step back706 assert evts == [1, 2]Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 707–708why, one step back707708Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 709why, one step back709def test_after_request_processing(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 710–711why, one step back710 @app.route("/")711 def index():Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 712–713why, one step back712 @flask.after_this_request713 def foo(response):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 714why, one step back714 response.headers["X-Foo"] = "a header"Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 715why, one step back715 return responseMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 716–719why, one step back716717 return "Test"718719 resp = client.get("/")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 720why, one step back720 assert resp.status_code == 200Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 721–723why, one step back721 assert resp.headers["X-Foo"] == "a header"722723Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 724why, one step back724def test_teardown_request_handler(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 725–741why, one step back725 called = []726727 @app.teardown_request728 def teardown_request(exc):729 called.append(True)730 return "Ignored"731732 @app.route("/")733 def root():734 return "Response"735736 rv = client.get("/")737 assert rv.status_code == 200738 assert b"Response" in rv.data739 assert len(called) == 1740741Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 742why, one step back742def test_teardown_request_handler_debug_mode(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 743–759why, one step back743 called = []744745 @app.teardown_request746 def teardown_request(exc):747 called.append(True)748 return "Ignored"749750 @app.route("/")751 def root():752 return "Response"753754 rv = client.get("/")755 assert rv.status_code == 200756 assert b"Response" in rv.data757 assert len(called) == 1758759Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 760why, one step back760def test_teardown_request_handler_error(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 761–764why, one step back761 called = []762 app.testing = False763764 @app.teardown_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 765why, one step back765 def teardown_request1(exc):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 766–772why, one step back766 assert type(exc) == ZeroDivisionError767 called.append(True)768 # This raises a new error and blows away sys.exc_info(), so we can769 # test that all teardown_requests get passed the same original770 # exception.771 try:772 raise TypeError()Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86
line 773why, one step back773 except Exception:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 774–776why, one step back774 pass775776 @app.teardown_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 777why, one step back777 def teardown_request2(exc):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 778–784why, one step back778 assert type(exc) == ZeroDivisionError779 called.append(True)780 # This raises a new error and blows away sys.exc_info(), so we can781 # test that all teardown_requests get passed the same original782 # exception.783 try:784 raise TypeError()Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86
line 785why, one step back785 except Exception:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 786–788why, one step back786 pass787788 @app.route("/")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 789why, one step back789 def fails():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 790–794why, one step back790 1 // 0791792 rv = client.get("/")793 assert rv.status_code == 500794 assert b"Internal Server Error" in rv.dataMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 795why, one step back795 assert len(called) == 2Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 796–797why, one step back796797Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 798why, one step back798def test_before_after_request_order(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 799–801why, one step back799 called = []800801 @app.before_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 802–803why, one step back802 def before1():803 called.append(1)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 804–805why, one step back804805 @app.before_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 806–807why, one step back806 def before2():807 called.append(2)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 808–809why, one step back808809 @app.after_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 810–811why, one step back810 def after1(response):811 called.append(4)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 812–814why, one step back812 return response813814 @app.after_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 815–816why, one step back815 def after2(response):816 called.append(3)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 817–819why, one step back817 return response818819 @app.teardown_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 820–821why, one step back820 def finish1(exc):821 called.append(6)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 822–823why, one step back822823 @app.teardown_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 824–825why, one step back824 def finish2(exc):825 called.append(5)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 826–832why, one step back826827 @app.route("/")828 def index():829 return "42"830831 rv = client.get("/")832 assert rv.data == b"42"Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 833why, one step back833 assert called == [1, 2, 3, 4, 5, 6]Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 834–835why, one step back834835Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 836why, one step back836def test_error_handling(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 837–839why, one step back837 app.testing = False838839 @app.errorhandler(404)Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 840why, one step back840 def not_found(e):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 841–846why, one step back841 return "not found", 404842843 @app.errorhandler(500)844 def internal_server_error(e):845 return "internal server error", 500846Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 847–848why, one step back847 @app.errorhandler(Forbidden)848 def forbidden(e):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 849–855why, one step back849 return "forbidden", 403850851 @app.route("/")852 def index():853 flask.abort(404)854855 @app.route("/error")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 856why, one step back856 def error():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 857–859why, one step back857 1 // 0858859 @app.route("/forbidden")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 860why, one step back860 def error2():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 861–869why, one step back861 flask.abort(403)862863 rv = client.get("/")864 assert rv.status_code == 404865 assert rv.data == b"not found"866 rv = client.get("/error")867 assert rv.status_code == 500868 assert b"internal server error" == rv.data869 rv = client.get("/forbidden")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 870why, one step back870 assert rv.status_code == 403Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 871–873why, one step back871 assert b"forbidden" == rv.data872873Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 874–875why, one step back874def test_error_handler_unknown_code(app):875 with pytest.raises(KeyError) as exc_info:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 876–880why, one step back876 app.register_error_handler(999, lambda e: ("999", 999))877878 assert "Use a subclass" in exc_info.value.args[0]879880Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 881why, one step back881def test_error_handling_processing(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 882–892why, one step back882 app.testing = False883884 @app.errorhandler(500)885 def internal_server_error(e):886 return "internal server error", 500887888 @app.route("/")889 def broken_func():890 1 // 0891892 @app.after_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 893why, one step back893 def after_request(resp):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 894why, one step back894 resp.mimetype = "text/x-special"Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 895why, one step back895 return respMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 896–901why, one step back896897 resp = client.get("/")898 assert resp.mimetype == "text/x-special"899 assert resp.data == b"internal server error"900901Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 902why, one step back902def test_baseexception_error_handling(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 903–906why, one step back903 app.testing = False904905 @app.route("/")906 def broken_func():Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 907why, one step back907 raise KeyboardInterrupt()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 908why, one step back908Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 909why, one step back909 with pytest.raises(KeyboardInterrupt):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 910–911why, one step back910 client.get("/")911Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 912–914why, one step back912 ctx = flask._request_ctx_stack.top913 assert ctx.preserved914 assert type(ctx._preserved_exc) is KeyboardInterruptMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 915–916why, one step back915916Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 917why, one step back917def test_before_request_and_routing_errors(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 918why, one step back918 @app.before_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 919why, one step back919 def attach_something():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 920–922why, one step back920 flask.g.something = "value"921922 @app.errorhandler(404)Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 923–924why, one step back923 def return_something(error):924 return flask.g.something, 404Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 925–930why, one step back925926 rv = client.get("/")927 assert rv.status_code == 404928 assert rv.data == b"value"929930Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 931–932why, one step back931def test_user_error_handling(app, client):932 class MyException(Exception):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 933–934why, one step back933 pass934Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 935–937why, one step back935 @app.errorhandler(MyException)936 def handle_my_exception(e):937 assert isinstance(e, MyException)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 938–941why, one step back938 return "42"939940 @app.route("/")941 def index():Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 942why, one step back942 raise MyException()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 943–946why, one step back943944 assert client.get("/").data == b"42"945946Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 947–948why, one step back947def test_http_error_subclass_handling(app, client):948 class ForbiddenSubclass(Forbidden):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 949–950why, one step back949 pass950Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 951why, one step back951 @app.errorhandler(ForbiddenSubclass)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 952why, one step back952 def handle_forbidden_subclass(e):Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 953why, one step back953 assert isinstance(e, ForbiddenSubclass)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 954–955why, one step back954 return "banana"955Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 956why, one step back956 @app.errorhandler(403)Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86
line 957why, one step back957 def handle_403(e):Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 958–959why, one step back958 assert not isinstance(e, ForbiddenSubclass)959 assert isinstance(e, Forbidden)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 960–962why, one step back960 return "apple"961962 @app.route("/1")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 963–964why, one step back963 def index1():964 raise ForbiddenSubclass()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 965–970why, one step back965966 @app.route("/2")967 def index2():968 flask.abort(403)969970 @app.route("/3")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 971–972why, one step back971 def index3():972 raise Forbidden()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 973–978why, one step back973974 assert client.get("/1").data == b"banana"975 assert client.get("/2").data == b"apple"976 assert client.get("/3").data == b"apple"977978Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 979–980why, one step back979def test_errorhandler_precedence(app, client):980 class E1(Exception):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 981–982why, one step back981 pass982Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 983why, one step back983 class E2(Exception):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 984–985why, one step back984 pass985Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 986why, one step back986 class E3(E1, E2):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 987–988why, one step back987 pass988Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 989–990why, one step back989 @app.errorhandler(E2)990 def handle_e2(e):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 991–992why, one step back991 return "E2"992Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 993–994why, one step back993 @app.errorhandler(Exception)994 def handle_exception(e):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 995–997why, one step back995 return "Exception"996997 @app.route("/E1")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 998–999why, one step back998 def raise_e1():999 raise E1Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1000–1001why, one step back10001001 @app.route("/E3")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1002–1003why, one step back1002 def raise_e3():1003 raise E3Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1004–1011why, one step back10041005 rv = client.get("/E1")1006 assert rv.data == b"Exception"10071008 rv = client.get("/E3")1009 assert rv.data == b"E2"10101011Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1012why, one step back1012def test_trapping_of_bad_request_key_errors(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1013–1017why, one step back1013 @app.route("/key")1014 def fail():1015 flask.request.form["missing_key"]10161017 @app.route("/abort")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1018–1019why, one step back1018 def allow_abort():1019 flask.abort(400)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1020–1027why, one step back10201021 rv = client.get("/key")1022 assert rv.status_code == 4001023 assert b"missing_key" not in rv.data1024 rv = client.get("/abort")1025 assert rv.status_code == 40010261027 app.debug = TrueMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1028why, one step back1028 with pytest.raises(KeyError) as e:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1029why, one step back1029 client.get("/key")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1030why, one step back1030 assert e.errisinstance(BadRequest)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1031–1036why, one step back1031 assert "missing_key" in e.value.get_description()1032 rv = client.get("/abort")1033 assert rv.status_code == 40010341035 app.debug = False1036 app.config["TRAP_BAD_REQUEST_ERRORS"] = TrueMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1037why, one step back1037 with pytest.raises(KeyError):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1038why, one step back1038 client.get("/key")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1039why, one step back1039 with pytest.raises(BadRequest):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1040–1042why, one step back1040 client.get("/abort")10411042Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1043why, one step back1043def test_trapping_of_all_http_exceptions(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1044–1049why, one step back1044 app.config["TRAP_HTTP_EXCEPTIONS"] = True10451046 @app.route("/fail")1047 def fail():1048 flask.abort(404)1049Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1050why, one step back1050 with pytest.raises(NotFound):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1051–1053why, one step back1051 client.get("/fail")10521053Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1054why, one step back1054def test_error_handler_after_processor_error(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1055–1058why, one step back1055 app.testing = False10561057 @app.before_request1058 def before_request():Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86
line 1059why, one step back1059 if _trigger == "before":Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1060–1063why, one step back1060 1 // 010611062 @app.after_request1063 def after_request(response):Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86
line 1064why, one step back1064 if _trigger == "after":Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1065–1075why, one step back1065 1 // 01066 return response10671068 @app.route("/")1069 def index():1070 return "Foo"10711072 @app.errorhandler(500)1073 def internal_server_error(e):1074 return "Hello Server Error", 5001075Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86
line 1076why, one step back1076 for _trigger in "before", "after":Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1077why, one step back1077 rv = client.get("/")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1078why, one step back1078 assert rv.status_code == 500Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1079–1081why, one step back1079 assert rv.data == b"Hello Server Error"10801081Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1082–1083why, one step back1082def test_enctype_debug_helper(app, client):1083 from flask.debughelpers import DebugFilesKeyErrorMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1084–1090why, one step back10841085 app.debug = True10861087 @app.route("/fail", methods=["POST"])1088 def index():1089 return flask.request.files["foo"].filename1090Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1091–1093why, one step back1091 # with statement is important because we leave an exception on the1092 # stack otherwise and we want to ensure that this is not the case1093 # to not negatively affect other tests.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1094why, one step back1094 with client:Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1095why, one step back1095 with pytest.raises(DebugFilesKeyError) as e:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1096–1097why, one step back1096 client.post("/fail", data={"foo": "index.txt"})1097 assert "no file contents were transmitted" in str(e.value)Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 1098why, one step back1098 assert "This was submitted: 'index.txt'" in str(e.value)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1099–1100why, one step back10991100Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1101why, one step back1101def test_response_types(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1102why, one step back1102 @app.route("/text")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1103why, one step back1103 def from_text():Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 1104why, one step back1104 return "Hällo Wörld"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1105–1106why, one step back11051106 @app.route("/bytes")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1107why, one step back1107 def from_bytes():Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 1108why, one step back1108 return "Hällo Wörld".encode()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1109–1110why, one step back11091110 @app.route("/full_tuple")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1111why, one step back1111 def from_full_tuple():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1112–1118why, one step back1112 return (1113 "Meh",1114 400,1115 {"X-Foo": "Testing", "Content-Type": "text/plain; charset=utf-8"},1116 )11171118 @app.route("/text_headers")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1119why, one step back1119 def from_text_headers():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1120–1122why, one step back1120 return "Hello", {"X-Foo": "Test", "Content-Type": "text/plain; charset=utf-8"}11211122 @app.route("/text_status")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1123why, one step back1123 def from_text_status():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1124–1126why, one step back1124 return "Hi, status!", 40011251126 @app.route("/response_headers")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1127why, one step back1127 def from_response_headers():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1128why, one step back1128 return (Merge pull request #3684 from MLH-Fellowship/3628-duplicate-headersDavid Lordbefore adoption2fa8eb3
lines 1129–1132why, one step back1129 flask.Response(1130 "Hello world", 404, {"Content-Type": "text/html", "X-Foo": "Baz"}1131 ),1132 {"Content-Type": "text/plain", "X-Foo": "Bar", "X-Bar": "Foo"},Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1133–1135why, one step back1133 )11341135 @app.route("/response_status")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1136why, one step back1136 def from_response_status():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1137–1139why, one step back1137 return app.response_class("Hello world", 400), 50011381139 @app.route("/wsgi")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1140–1141why, one step back1140 def from_wsgi():1141 return NotFound()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1142why, one step back1142Merge pull request #3229 from lordmauve/style-fixDavid Lordbefore adoption240e398
line 1143why, one step back1143 @app.route("/dict")Merge pull request #3111 from pgjones/masterDavid Lordbefore adoption855d59b
lines 1144–1145why, one step back1144 def from_dict():1145 return {"foo": "bar"}, 201Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1146why, one step back1146Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
lines 1147–1148why, one step back1147 assert client.get("/text").data == "Hällo Wörld".encode()1148 assert client.get("/bytes").data == "Hällo Wörld".encode()Merge pull request #3111 from pgjones/masterDavid Lordbefore adoption855d59b
line 1149why, one step back1149Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1150–1168why, one step back1150 rv = client.get("/full_tuple")1151 assert rv.data == b"Meh"1152 assert rv.headers["X-Foo"] == "Testing"1153 assert rv.status_code == 4001154 assert rv.mimetype == "text/plain"11551156 rv = client.get("/text_headers")1157 assert rv.data == b"Hello"1158 assert rv.headers["X-Foo"] == "Test"1159 assert rv.status_code == 2001160 assert rv.mimetype == "text/plain"11611162 rv = client.get("/text_status")1163 assert rv.data == b"Hi, status!"1164 assert rv.status_code == 4001165 assert rv.mimetype == "text/html"11661167 rv = client.get("/response_headers")1168 assert rv.data == b"Hello world"Merge pull request #3684 from MLH-Fellowship/3628-duplicate-headersDavid Lordbefore adoption2fa8eb3
lines 1169–1170why, one step back1169 assert rv.content_type == "text/plain"1170 assert rv.headers.getlist("X-Foo") == ["Bar"]Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1171–1180why, one step back1171 assert rv.headers["X-Bar"] == "Foo"1172 assert rv.status_code == 40411731174 rv = client.get("/response_status")1175 assert rv.data == b"Hello world"1176 assert rv.status_code == 50011771178 rv = client.get("/wsgi")1179 assert b"Not Found" in rv.data1180 assert rv.status_code == 404Merge pull request #3111 from pgjones/masterDavid Lordbefore adoption855d59b
line 1181why, one step back1181Merge pull request #3229 from lordmauve/style-fixDavid Lordbefore adoption240e398
line 1182why, one step back1182 rv = client.get("/dict")Merge pull request #3111 from pgjones/masterDavid Lordbefore adoption855d59b
lines 1183–1184why, one step back1183 assert rv.json == {"foo": "bar"}1184 assert rv.status_code == 201Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1185–1186why, one step back11851186Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1187why, one step back1187def test_response_type_errors():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1188–1191why, one step back1188 app = flask.Flask(__name__)1189 app.testing = True11901191 @app.route("/none")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1192why, one step back1192 def from_none():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1193–1195why, one step back1193 pass11941195 @app.route("/small_tuple")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1196why, one step back1196 def from_small_tuple():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1197–1199why, one step back1197 return ("Hello",)11981199 @app.route("/large_tuple")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1200why, one step back1200 def from_large_tuple():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1201–1203why, one step back1201 return "Hello", 234, {"X-Foo": "Bar"}, "???"12021203 @app.route("/bad_type")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1204–1205why, one step back1204 def from_bad_type():1205 return TrueMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1206–1207why, one step back12061207 @app.route("/bad_wsgi")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1208–1209why, one step back1208 def from_bad_wsgi():1209 return lambda: NoneMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1210–1214why, one step back12101211 c = app.test_client()12121213 with pytest.raises(TypeError) as e:1214 c.get("/none")Merge branch '1.0.x'David Lordbefore adoptionb05a685
line 1215why, one step back1215 assert "returned None" in str(e.value)Merge pull request #3498 from raymond-devries/3445-traceback-for-noneDavid Lordbefore adoptiona3e4395
line 1216why, one step back1216 assert "from_none" in str(e.value)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1217–1219why, one step back12171218 with pytest.raises(TypeError) as e:1219 c.get("/small_tuple")Merge branch '1.0.x'David Lordbefore adoptionb05a685
line 1220why, one step back1220 assert "tuple must have the form" in str(e.value)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1221–1225why, one step back12211222 pytest.raises(TypeError, c.get, "/large_tuple")12231224 with pytest.raises(TypeError) as e:1225 c.get("/bad_type")Merge branch '1.0.x'David Lordbefore adoptionb05a685
line 1226why, one step back1226 assert "it was a bool" in str(e.value)Merge pull request #3235 from johnzeringue/better-return-type-errorDavid Lordbefore adoption52f9aa7
line 1227why, one step back1227Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1228–1230why, one step back1228 pytest.raises(TypeError, c.get, "/bad_wsgi")12291230Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1231–1232why, one step back1231def test_make_response(app, req_ctx):1232 rv = flask.make_response()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1233–1247why, one step back1233 assert rv.status_code == 2001234 assert rv.data == b""1235 assert rv.mimetype == "text/html"12361237 rv = flask.make_response("Awesome")1238 assert rv.status_code == 2001239 assert rv.data == b"Awesome"1240 assert rv.mimetype == "text/html"12411242 rv = flask.make_response("W00t", 404)1243 assert rv.status_code == 4041244 assert rv.data == b"W00t"1245 assert rv.mimetype == "text/html"12461247Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1248why, one step back1248def test_make_response_with_response_instance(app, req_ctx):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1249–1250why, one step back1249 rv = flask.make_response(flask.jsonify({"msg": "W00t"}), 400)1250 assert rv.status_code == 400Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1251why, one step back1251 assert rv.data == b'{"msg":"W00t"}\n'Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1252–1268why, one step back1252 assert rv.mimetype == "application/json"12531254 rv = flask.make_response(flask.Response(""), 400)1255 assert rv.status_code == 4001256 assert rv.data == b""1257 assert rv.mimetype == "text/html"12581259 rv = flask.make_response(1260 flask.Response("", headers={"Content-Type": "text/html"}),1261 400,1262 [("X-Foo", "bar")],1263 )1264 assert rv.status_code == 4001265 assert rv.headers["Content-Type"] == "text/html"1266 assert rv.headers["X-Foo"] == "bar"12671268Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1269–1271why, one step back1269def test_jsonify_no_prettyprint(app, req_ctx):1270 app.config.update({"JSONIFY_PRETTYPRINT_REGULAR": False})1271 compressed_msg = b'{"msg":{"submsg":"W00t"},"msg2":"foobar"}\n'Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1272–1274why, one step back1272 uncompressed_msg = {"msg": {"submsg": "W00t"}, "msg2": "foobar"}12731274 rv = flask.make_response(flask.jsonify(uncompressed_msg), 200)Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1275why, one step back1275 assert rv.data == compressed_msgMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1276–1277why, one step back12761277Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1278–1280why, one step back1278def test_jsonify_prettyprint(app, req_ctx):1279 app.config.update({"JSONIFY_PRETTYPRINT_REGULAR": True})1280 compressed_msg = {"msg": {"submsg": "W00t"}, "msg2": "foobar"}Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1281why, one step back1281 pretty_response = (Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1282why, one step back1282 b'{\n "msg": {\n "submsg": "W00t"\n }, \n "msg2": "foobar"\n}\n'Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1283–1285why, one step back1283 )12841285 rv = flask.make_response(flask.jsonify(compressed_msg), 200)Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1286why, one step back1286 assert rv.data == pretty_responseMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1287–1288why, one step back12871288Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1289why, one step back1289def test_jsonify_mimetype(app, req_ctx):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1290–1294why, one step back1290 app.config.update({"JSONIFY_MIMETYPE": "application/vnd.api+json"})1291 msg = {"msg": {"submsg": "W00t"}}1292 rv = flask.make_response(flask.jsonify(msg), 200)1293 assert rv.mimetype == "application/vnd.api+json"1294Merge pull request #3195 from eruvanos/json_support_dataclassDavid Lordbefore adoptionb0185a6
lines 1295–1298why, one step back12951296@pytest.mark.skipif(sys.version_info < (3, 7), reason="requires Python >= 3.7")1297def test_json_dump_dataclass(app, req_ctx):1298 from dataclasses import make_dataclassMerge pull request #3229 from lordmauve/style-fixDavid Lordbefore adoption240e398
line 1299why, one step back1299Merge pull request #3195 from eruvanos/json_support_dataclassDavid Lordbefore adoptionb0185a6
lines 1300–1303why, one step back1300 Data = make_dataclass("Data", [("name", str)])1301 value = flask.json.dumps(Data("Flask"), app=app)1302 value = flask.json.loads(value, app=app)1303 assert value == {"name": "Flask"}Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1304why, one step back1304Merge pull request #3229 from lordmauve/style-fixDavid Lordbefore adoption240e398
line 1305why, one step back1305Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1306why, one step back1306def test_jsonify_args_and_kwargs_check(app, req_ctx):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1307–1311why, one step back1307 with pytest.raises(TypeError) as e:1308 flask.jsonify("fake args", kwargs="fake")1309 assert "behavior undefined" in str(e.value)13101311Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1312why, one step back1312def test_url_generation(app, req_ctx):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1313why, one step back1313 @app.route("/hello/<name>", methods=["POST"])Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1314why, one step back1314 def hello():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1315–1323why, one step back1315 pass13161317 assert flask.url_for("hello", name="test x") == "/hello/test%20x"1318 assert (1319 flask.url_for("hello", name="test x", _external=True)1320 == "http://localhost/hello/test%20x"1321 )13221323Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1324–1325why, one step back1324def test_build_error_handler(app):1325 # Test base case, a URL which results in a BuildError.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1326–1328why, one step back1326 with app.test_request_context():1327 pytest.raises(BuildError, flask.url_for, "spam")1328Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1329why, one step back1329 # Verify the error is re-raised if not the current exception.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1330why, one step back1330 try:Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1331why, one step back1331 with app.test_request_context():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1332why, one step back1332 flask.url_for("spam")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1333–1334why, one step back1333 except BuildError as err:1334 error = errMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1335–1336why, one step back1335 try:1336 raise RuntimeError("Test case where BuildError is not current.")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1337why, one step back1337 except RuntimeError:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1338–1339why, one step back1338 pytest.raises(BuildError, app.handle_url_build_error, error, "spam", {})1339Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1340why, one step back1340 # Test a custom handler.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1341why, one step back1341 def handler(error, endpoint, values):Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1342why, one step back1342 # Just a test.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1343–1344why, one step back1343 return "/test_handler/"1344Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1345why, one step back1345 app.url_build_error_handlers.append(handler)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1346–1349why, one step back1346 with app.test_request_context():1347 assert flask.url_for("spam") == "/test_handler/"13481349Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1350–1353why, one step back1350def test_build_error_handler_reraise(app):1351 # Test a custom handler which reraises the BuildError1352 def handler_raises_build_error(error, endpoint, values):1353 raise errorMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1354why, one step back1354Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1355why, one step back1355 app.url_build_error_handlers.append(handler_raises_build_error)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1356–1360why, one step back13561357 with app.test_request_context():1358 pytest.raises(BuildError, flask.url_for, "not.existing")13591360Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1361–1362why, one step back1361def test_url_for_passes_special_values_to_build_error_handler(app):1362 @app.url_build_error_handlers.appendMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1363why, one step back1363 def handler(error, endpoint, values):Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1364why, one step back1364 assert values == {Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1365–1375why, one step back1365 "_external": False,1366 "_anchor": None,1367 "_method": None,1368 "_scheme": None,1369 }1370 return "handled"13711372 with app.test_request_context():1373 flask.url_for("/")13741375Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1376why, one step back1376def test_static_files(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1377–1384why, one step back1377 rv = client.get("/static/index.html")1378 assert rv.status_code == 2001379 assert rv.data.strip() == b"<h1>Hello World!</h1>"1380 with app.test_request_context():1381 assert flask.url_for("static", filename="index.html") == "/static/index.html"1382 rv.close()13831384Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1385why, one step back1385def test_static_url_path():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1386–1395why, one step back1386 app = flask.Flask(__name__, static_url_path="/foo")1387 app.testing = True1388 rv = app.test_client().get("/foo/index.html")1389 assert rv.status_code == 2001390 rv.close()13911392 with app.test_request_context():1393 assert flask.url_for("static", filename="index.html") == "/foo/index.html"13941395Merge pull request #3182 from qil026/issue-3134-url-joinDavid Lordbefore adoptiondbd3840
lines 1396–1406why, one step back1396def test_static_url_path_with_ending_slash():1397 app = flask.Flask(__name__, static_url_path="/foo/")1398 app.testing = True1399 rv = app.test_client().get("/foo/index.html")1400 assert rv.status_code == 2001401 rv.close()14021403 with app.test_request_context():1404 assert flask.url_for("static", filename="index.html") == "/foo/index.html"14051406Merge pull request #3124 from elbeardmorez/fix_static_url_pathDavid Lordbefore adoption754b729
line 1407why, one step back1407def test_static_url_empty_path(app):Merge pull request #3229 from lordmauve/style-fixDavid Lordbefore adoption240e398
lines 1408–1409why, one step back1408 app = flask.Flask(__name__, static_folder="", static_url_path="")1409 rv = app.test_client().open("/static/index.html", method="GET")Merge pull request #3124 from elbeardmorez/fix_static_url_pathDavid Lordbefore adoption754b729
lines 1410–1414why, one step back1410 assert rv.status_code == 2001411 rv.close()141214131414def test_static_url_empty_path_default(app):Merge pull request #3229 from lordmauve/style-fixDavid Lordbefore adoption240e398
lines 1415–1416why, one step back1415 app = flask.Flask(__name__, static_folder="")1416 rv = app.test_client().open("/static/index.html", method="GET")Merge pull request #3124 from elbeardmorez/fix_static_url_pathDavid Lordbefore adoption754b729
lines 1417–1420why, one step back1417 assert rv.status_code == 2001418 rv.close()14191420Merge pull request #3579 from jab/pathlib-for-static_folderJoshua Bronsonbefore adoptioncf5b1d0
lines 1421–1430why, one step back1421@pytest.mark.skipif(sys.version_info < (3, 6), reason="requires Python >= 3.6")1422def test_static_folder_with_pathlib_path(app):1423 from pathlib import Path14241425 app = flask.Flask(__name__, static_folder=Path("static"))1426 rv = app.test_client().open("/static/index.html", method="GET")1427 assert rv.status_code == 2001428 rv.close()14291430Merge remote-tracking branch 'origin/1.1.x'David Lordbefore adoption64ba434
lines 1431–1441why, one step back1431def test_static_folder_with_ending_slash():1432 app = flask.Flask(__name__, static_folder="static/")14331434 @app.route("/<path:path>")1435 def catch_all(path):1436 return path14371438 rv = app.test_client().get("/catch/all")1439 assert rv.data == b"catch/all"14401441Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1442why, one step back1442def test_static_route_with_host_matching():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1443–1450why, one step back1443 app = flask.Flask(__name__, host_matching=True, static_host="example.com")1444 c = app.test_client()1445 rv = c.get("http://example.com/static/index.html")1446 assert rv.status_code == 2001447 rv.close()1448 with app.test_request_context():1449 rv = flask.url_for("static", filename="index.html", _external=True)1450 assert rv == "http://example.com/static/index.html"Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1451why, one step back1451 # Providing static_host without host_matching=True should error.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1452–1453why, one step back1452 with pytest.raises(Exception):1453 flask.Flask(__name__, static_host="example.com")Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86
lines 1454–1455why, one step back1454 # Providing host_matching=True with static_folder1455 # but without static_host should error.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1456why, one step back1456 with pytest.raises(Exception):Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1457why, one step back1457 flask.Flask(__name__, host_matching=True)Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86
lines 1458–1459why, one step back1458 # Providing host_matching=True without static_host1459 # but with static_folder=None should not error.Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1460why, one step back1460 flask.Flask(__name__, host_matching=True, static_folder=None)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1461–1462why, one step back14611462Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1463why, one step back1463def test_request_locals():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1464why, one step back1464 assert repr(flask.g) == "<LocalProxy unbound>"Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1465why, one step back1465 assert not flask.gMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1466–1467why, one step back14661467Merge branch '1.0.x'David Lordbefore adoption29111a3
line 1468why, one step back1468def test_server_name_subdomain():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1469–1473why, one step back1469 app = flask.Flask(__name__, subdomain_matching=True)1470 client = app.test_client()14711472 @app.route("/")1473 def index():Merge branch '1.0.x'David Lordbefore adoption29111a3
line 1474why, one step back1474 return "default"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1475–1476why, one step back14751476 @app.route("/", subdomain="foo")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1477why, one step back1477 def subdomain():Merge branch '1.0.x'David Lordbefore adoption29111a3
line 1478why, one step back1478 return "subdomain"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1479why, one step back1479Merge branch '1.0.x'David Lordbefore adoption29111a3
line 1480why, one step back1480 app.config["SERVER_NAME"] = "dev.local:5000"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1481why, one step back1481 rv = client.get("/")Merge branch '1.0.x'David Lordbefore adoption29111a3
line 1482why, one step back1482 assert rv.data == b"default"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1483why, one step back1483Merge branch '1.0.x'David Lordbefore adoption29111a3
lines 1484–1485why, one step back1484 rv = client.get("/", "http://dev.local:5000")1485 assert rv.data == b"default"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1486why, one step back1486Merge branch '1.0.x'David Lordbefore adoption29111a3
lines 1487–1488why, one step back1487 rv = client.get("/", "https://dev.local:5000")1488 assert rv.data == b"default"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1489why, one step back1489Merge branch '1.0.x'David Lordbefore adoption29111a3
lines 1490–1491why, one step back1490 app.config["SERVER_NAME"] = "dev.local:443"1491 rv = client.get("/", "https://dev.local")Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1492why, one step back1492Merge branch '1.0.x'David Lordbefore adoption29111a3
lines 1493–1495why, one step back1493 # Werkzeug 1.0 fixes matching https scheme with 443 port1494 if rv.status_code != 404:1495 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–1502why, one step back1497 app.config["SERVER_NAME"] = "dev.local"1498 rv = client.get("/", "https://dev.local")1499 assert rv.data == b"default"15001501 # suppress Werkzeug 1.0 warning about name mismatch1502 with pytest.warns(None):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1503–1505why, one step back1503 rv = client.get("/", "http://foo.localhost")1504 assert rv.status_code == 4041505Merge branch '1.0.x'David Lordbefore adoption29111a3
lines 1506–1507why, one step back1506 rv = client.get("/", "http://foo.dev.local")1507 assert rv.data == b"subdomain"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1508–1509why, one step back15081509Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1510–1511why, one step back1510def test_exception_propagation(app, client):1511 def apprunner(config_key):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1512–1515why, one step back1512 @app.route("/")1513 def index():1514 1 // 01515Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1516–1518why, one step back1516 if config_key is not None:1517 app.config[config_key] = True1518 with pytest.raises(Exception):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1519–1522why, one step back1519 client.get("/")1520 else:1521 assert client.get("/").status_code == 5001522Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1523–1526why, one step back1523 # we have to run this test in an isolated thread because if the1524 # debug flag is set to true and an exception happens the context is1525 # not torn down. This causes other tests that run after this fail1526 # when they expect no exception on the stack.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1527why, one step back1527 for config_key in "TESTING", "PROPAGATE_EXCEPTIONS", "DEBUG", None:Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1528–1530why, one step back1528 t = Thread(target=apprunner, args=(config_key,))1529 t.start()1530 t.join()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1531–1547why, one step back153115321533@pytest.mark.parametrize("debug", [True, False])1534@pytest.mark.parametrize("use_debugger", [True, False])1535@pytest.mark.parametrize("use_reloader", [True, False])1536@pytest.mark.parametrize("propagate_exceptions", [None, True, False])1537def test_werkzeug_passthrough_errors(1538 monkeypatch, debug, use_debugger, use_reloader, propagate_exceptions, app1539):1540 rv = {}15411542 # Mocks werkzeug.serving.run_simple method1543 def run_simple_mock(*args, **kwargs):1544 rv["passthrough_errors"] = kwargs.get("passthrough_errors")15451546 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)1547 app.config["PROPAGATE_EXCEPTIONS"] = propagate_exceptionsMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1548why, one step back1548 app.run(debug=debug, use_debugger=use_debugger, use_reloader=use_reloader)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1549–1550why, one step back15491550Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1551why, one step back1551def test_max_content_length(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1552–1554why, one step back1552 app.config["MAX_CONTENT_LENGTH"] = 6415531554 @app.before_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1555why, one step back1555 def always_first():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1556why, one step back1556 flask.request.form["myfile"]Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86
line 1557why, one step back1557 AssertionError()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1558–1559why, one step back15581559 @app.route("/accept", methods=["POST"])Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1560why, one step back1560 def accept_file():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1561why, one step back1561 flask.request.form["myfile"]Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86
line 1562why, one step back1562 AssertionError()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1563why, one step back1563Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1564–1565why, one step back1564 @app.errorhandler(413)1565 def catcher(error):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1566–1571why, one step back1566 return "42"15671568 rv = client.post("/accept", data={"myfile": "foo" * 100})1569 assert rv.data == b"42"15701571Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1572–1574why, one step back1572def test_url_processors(app, client):1573 @app.url_defaults1574 def add_language_code(endpoint, values):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1575–1579why, one step back1575 if flask.g.lang_code is not None and app.url_map.is_endpoint_expecting(1576 endpoint, "lang_code"1577 ):1578 values.setdefault("lang_code", flask.g.lang_code)1579Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1580–1581why, one step back1580 @app.url_value_preprocessor1581 def pull_lang_code(endpoint, values):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1582–1588why, one step back1582 flask.g.lang_code = values.pop("lang_code", None)15831584 @app.route("/<lang_code>/")1585 def index():1586 return flask.url_for("about")15871588 @app.route("/<lang_code>/about")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1589why, one step back1589 def about():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1590–1592why, one step back1590 return flask.url_for("something_else")15911592 @app.route("/foo")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1593why, one step back1593 def something_else():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1594–1600why, one step back1594 return flask.url_for("about", lang_code="en")15951596 assert client.get("/de/").data == b"/de/about"1597 assert client.get("/de/about").data == b"/foo"1598 assert client.get("/foo").data == b"/en/about"15991600Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1601why, one step back1601def test_inject_blueprint_url_defaults(app):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1602–1603why, one step back1602 bp = flask.Blueprint("foo.bar.baz", __name__, template_folder="template")1603Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1604–1605why, one step back1604 @bp.url_defaults1605 def bp_defaults(endpoint, values):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1606–1608why, one step back1606 values["page"] = "login"16071608 @bp.route("/<page>")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1609why, one step back1609 def view(page):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1610–1611why, one step back1610 pass1611Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1612why, one step back1612 app.register_blueprint(bp)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1613why, one step back1613Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1614why, one step back1614 values = dict()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1615–1616why, one step back1615 app.inject_url_defaults("foo.bar.baz.view", values)1616 expected = dict(page="login")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1617why, one step back1617 assert values == expectedMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1618–1621why, one step back16181619 with app.test_request_context("/somepage"):1620 url = flask.url_for("foo.bar.baz.view")1621 expected = "/login"Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1622why, one step back1622 assert url == expectedMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1623–1624why, one step back16231624Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1625why, one step back1625def test_nonascii_pathinfo(app, client):Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 1626why, one step back1626 @app.route("/киртест")Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1627–1629why, one step back1627 def index():1628 return "Hello World!"1629Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 1630why, one step back1630 rv = client.get("/киртест")Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1631–1633why, one step back1631 assert rv.data == b"Hello World!"16321633Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1634why, one step back1634def test_debug_mode_complains_after_first_request(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1635–1640why, one step back1635 app.debug = True16361637 @app.route("/")1638 def index():1639 return "Awesome"1640Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1641why, one step back1641 assert not app.got_first_requestMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1642why, one step back1642 assert client.get("/").data == b"Awesome"Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1643why, one step back1643 with pytest.raises(AssertionError) as e:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1644–1645why, one step back16441645 @app.route("/foo")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1646why, one step back1646 def broken():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1647–1648why, one step back1647 return "Meh"1648Merge branch '1.0.x'David Lordbefore adoptionb05a685
line 1649why, one step back1649 assert "A setup function was called" in str(e.value)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1650–1653why, one step back16501651 app.debug = False16521653 @app.route("/foo")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1654why, one step back1654 def working():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1655–1660why, one step back1655 return "Meh"16561657 assert client.get("/foo").data == b"Meh"1658 assert app.got_first_request16591660Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1661why, one step back1661def test_before_first_request_functions(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1662–1674why, one step back1662 got = []16631664 @app.before_first_request1665 def foo():1666 got.append(42)16671668 client.get("/")1669 assert got == [42]1670 client.get("/")1671 assert got == [42]1672 assert app.got_first_request16731674Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1675why, one step back1675def test_before_first_request_functions_concurrent(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1676–1679why, one step back1676 got = []16771678 @app.before_first_request1679 def foo():Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1680why, one step back1680 time.sleep(0.2)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1681–1682why, one step back1681 got.append(42)1682Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1683why, one step back1683 def get_and_assert():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1684why, one step back1684 client.get("/")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1685why, one step back1685 assert got == [42]Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1686why, one step back1686Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1687–1690why, one step back1687 t = Thread(target=get_and_assert)1688 t.start()1689 get_and_assert()1690 t.join()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1691–1693why, one step back1691 assert app.got_first_request16921693Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1694why, one step back1694def test_routing_redirect_debugging(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1695–1701why, one step back1695 app.debug = True16961697 @app.route("/foo/", methods=["GET", "POST"])1698 def foo():1699 return "success"17001701 with client:Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1702why, one step back1702 with pytest.raises(AssertionError) as e:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1703why, one step back1703 client.post("/foo", data={})Merge branch '1.0.x'David Lordbefore adoptionb05a685
line 1704why, one step back1704 assert "http://localhost/foo/" in str(e.value)Merge pull request #3453 from noviluni/remove_redundant_parenthesesDavid Lordbefore adoption986871b
line 1705why, one step back1705 assert "Make sure to directly send your POST-request to this URL" in str(Merge branch '1.0.x'David Lordbefore adoptionb05a685
lines 1706–1707why, one step back1706 e.value1707 )Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1708–1717why, one step back17081709 rv = client.get("/foo", data={}, follow_redirects=True)1710 assert rv.data == b"success"17111712 app.debug = False1713 with client:1714 rv = client.post("/foo", data={}, follow_redirects=True)1715 assert rv.data == b"success"17161717Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1718why, one step back1718def test_route_decorator_custom_endpoint(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1719–1725why, one step back1719 app.debug = True17201721 @app.route("/foo/")1722 def foo():1723 return flask.request.endpoint17241725 @app.route("/bar/", endpoint="bar")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1726why, one step back1726 def for_bar():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1727–1729why, one step back1727 return flask.request.endpoint17281729 @app.route("/bar/123", endpoint="123")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1730why, one step back1730 def for_bar_foo():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1731–1742why, one step back1731 return flask.request.endpoint17321733 with app.test_request_context():1734 assert flask.url_for("foo") == "/foo/"1735 assert flask.url_for("bar") == "/bar/"1736 assert flask.url_for("123") == "/bar/123"17371738 assert client.get("/foo/").data == b"foo"1739 assert client.get("/bar/").data == b"bar"1740 assert client.get("/bar/123").data == b"123"17411742Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1743why, one step back1743def test_preserve_only_once(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1744–1749why, one step back1744 app.debug = True17451746 @app.route("/fail")1747 def fail_func():1748 1 // 01749Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86
line 1750why, one step back1750 for _x in range(3):Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1751why, one step back1751 with pytest.raises(ZeroDivisionError):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1752–1753why, one step back1752 client.get("/fail")1753Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1754–1759why, one step back1754 assert flask._request_ctx_stack.top is not None1755 assert flask._app_ctx_stack.top is not None1756 # implicit appctx disappears too1757 flask._request_ctx_stack.top.pop()1758 assert flask._request_ctx_stack.top is None1759 assert flask._app_ctx_stack.top is NoneMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1760–1761why, one step back17601761Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1762why, one step back1762def test_preserve_remembers_exception(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1763why, one step back1763 app.debug = TrueMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1764why, one step back1764 errors = []Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1765–1770why, one step back17651766 @app.route("/fail")1767 def fail_func():1768 1 // 017691770 @app.route("/success")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1771why, one step back1771 def success_func():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1772–1774why, one step back1772 return "Okay"17731774 @app.teardown_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1775–1776why, one step back1775 def teardown_handler(exc):1776 errors.append(exc)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1777why, one step back1777Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1778–1779why, one step back1778 # After this failure we did not yet call the teardown handler1779 with pytest.raises(ZeroDivisionError):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1780why, one step back1780 client.get("/fail")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1781why, one step back1781 assert errors == []Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1782why, one step back1782Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1783why, one step back1783 # But this request triggers it, and it's an errorMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1784why, one step back1784 client.get("/success")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1785–1786why, one step back1785 assert len(errors) == 21786 assert isinstance(errors[0], ZeroDivisionError)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1787why, one step back1787Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1788why, one step back1788 # At this point another request does nothing.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1789why, one step back1789 client.get("/success")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1790–1791why, one step back1790 assert len(errors) == 31791 assert errors[1] is NoneMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1792–1793why, one step back17921793Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1794why, one step back1794def test_get_method_on_g(app_ctx):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1795–1796why, one step back1795 assert flask.g.get("x") is None1796 assert flask.g.get("x", 11) == 11Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1797why, one step back1797 flask.g.x = 42Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1798why, one step back1798 assert flask.g.get("x") == 42Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1799why, one step back1799 assert flask.g.x == 42Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1800–1801why, one step back18001801Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1802–1804why, one step back1802def test_g_iteration_protocol(app_ctx):1803 flask.g.foo = 231804 flask.g.bar = 42Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1805–1809why, one step back1805 assert "foo" in flask.g1806 assert "foos" not in flask.g1807 assert sorted(flask.g) == ["bar", "foo"]18081809Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1810why, one step back1810def test_subdomain_basic_support():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1811–1815why, one step back1811 app = flask.Flask(__name__, subdomain_matching=True)1812 app.config["SERVER_NAME"] = "localhost.localdomain"1813 client = app.test_client()18141815 @app.route("/")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1816why, one step back1816 def normal_index():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1817–1819why, one step back1817 return "normal index"18181819 @app.route("/", subdomain="test")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1820why, one step back1820 def test_index():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1821–1829why, one step back1821 return "test index"18221823 rv = client.get("/", "http://localhost.localdomain/")1824 assert rv.data == b"normal index"18251826 rv = client.get("/", "http://test.localhost.localdomain/")1827 assert rv.data == b"test index"18281829Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1830why, one step back1830def test_subdomain_matching():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1831–1836why, one step back1831 app = flask.Flask(__name__, subdomain_matching=True)1832 client = app.test_client()1833 app.config["SERVER_NAME"] = "localhost.localdomain"18341835 @app.route("/", subdomain="<user>")1836 def index(user):Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 1837why, one step back1837 return f"index for {user}"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1838–1842why, one step back18381839 rv = client.get("/", "http://mitsuhiko.localhost.localdomain/")1840 assert rv.data == b"index for mitsuhiko"18411842Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1843why, one step back1843def test_subdomain_matching_with_ports():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1844–1849why, one step back1844 app = flask.Flask(__name__, subdomain_matching=True)1845 app.config["SERVER_NAME"] = "localhost.localdomain:3000"1846 client = app.test_client()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–1856why, one step back18511852 rv = client.get("/", "http://mitsuhiko.localhost.localdomain:3000/")1853 assert rv.data == b"index for mitsuhiko"185418551856@pytest.mark.parametrize("matching", (False, True))Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1857–1858why, one step back1857def test_subdomain_matching_other_name(matching):1858 app = flask.Flask(__name__, subdomain_matching=matching)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1859–1865why, one step back1859 app.config["SERVER_NAME"] = "localhost.localdomain:3000"1860 client = app.test_client()18611862 @app.route("/")1863 def index():1864 return "", 2041865Merge branch '1.0.x'David Lordbefore adoption29111a3
lines 1866–1870why, one step back1866 # suppress Werkzeug 0.15 warning about name mismatch1867 with pytest.warns(None):1868 # ip address can't match name1869 rv = client.get("/", "http://127.0.0.1:3000/")1870 assert rv.status_code == 404 if matching else 204Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1871why, one step back1871Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1872why, one step back1872 # allow all subdomains if matching is disabledMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1873–1876why, one step back1873 rv = client.get("/", "http://www.localhost.localdomain:3000/")1874 assert rv.status_code == 404 if matching else 20418751876Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1877why, one step back1877def test_multi_route_rules(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1878–1880why, one step back1878 @app.route("/")1879 @app.route("/<test>/")1880 def index(test="a"):Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1881why, one step back1881 return testMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1882–1888why, one step back18821883 rv = client.open("/")1884 assert rv.data == b"a"1885 rv = client.open("/b/")1886 assert rv.data == b"b"18871888Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1889why, one step back1889def test_multi_route_class_views(app, client):Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 1890why, one step back1890 class View:Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1891why, one step back1891 def __init__(self, app):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1892–1895why, one step back1892 app.add_url_rule("/", "index", self.index)1893 app.add_url_rule("/<test>/", "index", self.index)18941895 def index(self, test="a"):Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1896why, one step back1896 return testMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1897why, one step back1897Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1898why, one step back1898 _ = View(app)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1899–1904why, one step back1899 rv = client.open("/")1900 assert rv.data == b"a"1901 rv = client.open("/b/")1902 assert rv.data == b"b"19031904Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1905why, one step back1905def test_run_defaults(monkeypatch, app):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1906–1912why, one step back1906 rv = {}19071908 # Mocks werkzeug.serving.run_simple method1909 def run_simple_mock(*args, **kwargs):1910 rv["result"] = "running..."19111912 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1913why, one step back1913 app.run()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1914–1916why, one step back1914 assert rv["result"] == "running..."19151916Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1917why, one step back1917def test_run_server_port(monkeypatch, app):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1918–1920why, one step back1918 rv = {}19191920 # Mocks werkzeug.serving.run_simple methodMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1921why, one step back1921 def run_simple_mock(hostname, port, application, *args, **kwargs):Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 1922why, one step back1922 rv["result"] = f"running on {hostname}:{port} ..."Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1923–1925why, one step back19231924 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)1925 hostname, port = "localhost", 8000Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1926why, one step back1926 app.run(hostname, port, debug=True)Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 1927why, one step back1927 assert rv["result"] == f"running on {hostname}:{port} ..."Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1928–1930why, one step back192819291930@pytest.mark.parametrize(Merge pull request #2928 from vorelq/2926-default-port-overrides-zeroDavid Lordbefore adoptiond9fa28b
line 1931why, one step back1931 "host,port,server_name,expect_host,expect_port",Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1932why, one step back1932 (Merge pull request #2928 from vorelq/2926-default-port-overrides-zeroDavid Lordbefore adoptiond9fa28b
lines 1933–1939why, one step back1933 (None, None, "pocoo.org:8080", "pocoo.org", 8080),1934 ("localhost", None, "pocoo.org:8080", "localhost", 8080),1935 (None, 80, "pocoo.org:8080", "pocoo.org", 80),1936 ("localhost", 80, "pocoo.org:8080", "localhost", 80),1937 ("localhost", 0, "localhost:8080", "localhost", 0),1938 (None, None, "localhost:8080", "localhost", 8080),1939 (None, None, "localhost:0", "localhost", 0),Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1940–1941why, one step back1940 ),1941)Merge pull request #3229 from lordmauve/style-fixDavid Lordbefore adoption240e398
lines 1942–1944why, one step back1942def test_run_from_config(1943 monkeypatch, host, port, server_name, expect_host, expect_port, app1944):Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1945–1947why, one step back1945 def run_simple_mock(hostname, port, *args, **kwargs):1946 assert hostname == expect_host1947 assert port == expect_portMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1948–1949why, one step back19481949 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)Merge pull request #2928 from vorelq/2926-default-port-overrides-zeroDavid Lordbefore adoptiond9fa28b
line 1950why, one step back1950 app.config["SERVER_NAME"] = server_nameMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1951why, one step back1951 app.run(host, port)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1952–1953why, one step back19521953Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1954why, one step back1954def test_max_cookie_size(app, client, recwarn):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1955–1956why, one step back1955 app.config["MAX_COOKIE_SIZE"] = 1001956Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1957–1959why, one step back1957 # outside app context, default to Werkzeug static value,1958 # which is also the default config1959 response = flask.Response()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1960why, one step back1960 default = flask.Flask.default_config["MAX_COOKIE_SIZE"]Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1961why, one step back1961 assert response.max_cookie_size == defaultMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1962why, one step back1962Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1963–1965why, one step back1963 # inside app context, use app config1964 with app.app_context():1965 assert flask.Response().max_cookie_size == 100Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1966–1970why, one step back19661967 @app.route("/")1968 def index():1969 r = flask.Response("", status=204)1970 r.set_cookie("foo", "bar" * 100)Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1971why, one step back1971 return rMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1972–1973why, one step back19721973 client.get("/")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1974–1975why, one step back1974 assert len(recwarn) == 11975 w = recwarn.pop()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1976–1980why, one step back1976 assert "cookie is too large" in str(w.message)19771978 app.config["MAX_COOKIE_SIZE"] = 019791980 client.get("/")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1981why, one step back1981 assert len(recwarn) == 0Break reference cycle created by default in Flask instances.Bogdan Opanchukbefore adoption8efea0c
lines 1982–1997why, one step back198219831984@require_cpython_gc1985def test_app_freed_on_zero_refcount():1986 # A Flask instance should not create a reference cycle that prevents CPython1987 # from freeing it when all external references to it are released (see #3761).1988 gc.disable()1989 try:1990 app = flask.Flask(__name__)1991 assert app.view_functions["static"]1992 weak = weakref.ref(app)1993 assert weak() is not None1994 del app1995 assert weak() is None1996 finally:1997 gc.enable()