test_basic.py
This file
Path
tests/test_basic.py
1,996 lines · 53.6 KiB · Python
Last changed by
Break reference cycle created by default in Flask instances.Bogdan Opanchukbefore adoption8efea0c
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
lines 22–26why, one step back22require_cpython_gc = pytest.mark.skipif(23 python_implementation() != "CPython", reason="Requires CPython GC behavior",24)2526Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 27why, one step back27def test_options_work(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 28–36why, one step back28 @app.route("/", methods=["GET", "POST"])29 def index():30 return "Hello World"3132 rv = client.open("/", method="OPTIONS")33 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS", "POST"]34 assert rv.data == b""3536Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 37why, one step back37def test_options_on_multiple_rules(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 38–42why, one step back38 @app.route("/", methods=["GET", "POST"])39 def index():40 return "Hello World"4142 @app.route("/", methods=["PUT"])Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 43why, one step back43 def index_put():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 44–49why, one step back44 return "Aha!"4546 rv = client.open("/", method="OPTIONS")47 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS", "POST", "PUT"]4849Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 50why, one step back50def test_provide_automatic_options_attr():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 51–55why, one step back51 app = flask.Flask(__name__)5253 def index():54 return "Hello World!"55Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 56why, one step back56 index.provide_automatic_options = FalseMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 57–65why, one step back57 app.route("/")(index)58 rv = app.test_client().open("/", method="OPTIONS")59 assert rv.status_code == 4056061 app = flask.Flask(__name__)6263 def index2():64 return "Hello World!"65Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 66why, one step back66 index2.provide_automatic_options = TrueMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 67–71why, one step back67 app.route("/", methods=["OPTIONS"])(index2)68 rv = app.test_client().open("/", method="OPTIONS")69 assert sorted(rv.allow) == ["OPTIONS"]7071Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 72why, one step back72def test_provide_automatic_options_kwarg(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 73–79why, one step back73 def index():74 return flask.request.method7576 def more():77 return flask.request.method7879 app.add_url_rule("/", view_func=index, provide_automatic_options=False)Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 80why, one step back80 app.add_url_rule(Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 81–91why, one step back81 "/more",82 view_func=more,83 methods=["GET", "POST"],84 provide_automatic_options=False,85 )86 assert client.get("/").data == b"GET"8788 rv = client.post("/")89 assert rv.status_code == 40590 assert sorted(rv.allow) == ["GET", "HEAD"]91Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 92why, one step back92 rv = client.open("/", method="OPTIONS")Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 93–104why, one step back93 assert rv.status_code == 4059495 rv = client.head("/")96 assert rv.status_code == 20097 assert not rv.data # head truncates98 assert client.post("/more").data == b"POST"99 assert client.get("/more").data == b"GET"100101 rv = client.delete("/more")102 assert rv.status_code == 405103 assert sorted(rv.allow) == ["GET", "HEAD", "POST"]104Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 105why, one step back105 rv = client.open("/more", method="OPTIONS")Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 106–108why, one step back106 assert rv.status_code == 405107108Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 109why, one step back109def test_request_dispatching(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 110–131why, one step back110 @app.route("/")111 def index():112 return flask.request.method113114 @app.route("/more", methods=["GET", "POST"])115 def more():116 return flask.request.method117118 assert client.get("/").data == b"GET"119 rv = client.post("/")120 assert rv.status_code == 405121 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS"]122 rv = client.head("/")123 assert rv.status_code == 200124 assert not rv.data # head truncates125 assert client.post("/more").data == b"POST"126 assert client.get("/more").data == b"GET"127 rv = client.delete("/more")128 assert rv.status_code == 405129 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS", "POST"]130131Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 132–133why, one step back132def test_disallow_string_for_allowed_methods(app):133 with pytest.raises(TypeError):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 134–136why, one step back134135 @app.route("/", methods="GET POST")136 def index():Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 137why, one step back137 return "Hey"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 138–139why, one step back138139Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 140–141why, one step back140def test_url_mapping(app, client):141 random_uuid4 = "7eb41166-9ebf-4d26-b771-ea3f54f8b383"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 142–148why, one step back142143 def index():144 return flask.request.method145146 def more():147 return flask.request.method148Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 149–150why, one step back149 def options():150 return random_uuid4Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 151–154why, one step back151152 app.add_url_rule("/", "index", index)153 app.add_url_rule("/more", "more", more, methods=["GET", "POST"])154Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86
lines 155–156why, one step back155 # Issue 1288: Test that automatic options are not added156 # when non-uppercase 'options' in methodsMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 157–172why, one step back157 app.add_url_rule("/options", "options", options, methods=["options"])158159 assert client.get("/").data == b"GET"160 rv = client.post("/")161 assert rv.status_code == 405162 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS"]163 rv = client.head("/")164 assert rv.status_code == 200165 assert not rv.data # head truncates166 assert client.post("/more").data == b"POST"167 assert client.get("/more").data == b"GET"168 rv = client.delete("/more")169 assert rv.status_code == 405170 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS", "POST"]171 rv = client.open("/options", method="OPTIONS")172 assert rv.status_code == 200Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 173why, one step back173 assert random_uuid4 in rv.data.decode("utf-8")Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 174–175why, one step back174175Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 176why, one step back176def test_werkzeug_routing(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 177–195why, one step back177 from werkzeug.routing import Submount, Rule178179 app.url_map.add(180 Submount("/foo", [Rule("/bar", endpoint="bar"), Rule("/", endpoint="index")])181 )182183 def bar():184 return "bar"185186 def index():187 return "index"188189 app.view_functions["bar"] = bar190 app.view_functions["index"] = index191192 assert client.get("/foo/").data == b"index"193 assert client.get("/foo/bar").data == b"bar"194195Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 196why, one step back196def test_endpoint_decorator(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 197–214why, one step back197 from werkzeug.routing import Submount, Rule198199 app.url_map.add(200 Submount("/foo", [Rule("/bar", endpoint="bar"), Rule("/", endpoint="index")])201 )202203 @app.endpoint("bar")204 def bar():205 return "bar"206207 @app.endpoint("index")208 def index():209 return "index"210211 assert client.get("/foo/").data == b"index"212 assert client.get("/foo/bar").data == b"bar"213214Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 215why, one step back215def test_session(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 216why, one step back216 @app.route("/set", methods=["POST"])Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 217why, one step back217 def set():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 218–221why, one step back218 assert not flask.session.accessed219 assert not flask.session.modified220 flask.session["value"] = flask.request.form["value"]221 assert flask.session.accessedMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 222why, one step back222 assert flask.session.modifiedMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 223–231why, one step back223 return "value set"224225 @app.route("/get")226 def get():227 assert not flask.session.accessed228 assert not flask.session.modified229 v = flask.session.get("value", "None")230 assert flask.session.accessed231 assert not flask.session.modifiedMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 232why, one step back232 return vMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 233–237why, one step back233234 assert client.post("/set", data={"value": "42"}).data == b"value set"235 assert client.get("/get").data == b"42"236237Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 238why, one step back238def test_session_using_server_name(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 239–250why, one step back239 app.config.update(SERVER_NAME="example.com")240241 @app.route("/")242 def index():243 flask.session["testing"] = 42244 return "Hello World"245246 rv = client.get("/", "http://example.com/")247 assert "domain=.example.com" in rv.headers["set-cookie"].lower()248 assert "httponly" in rv.headers["set-cookie"].lower()249250Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 251why, one step back251def test_session_using_server_name_and_port(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 252–263why, one step back252 app.config.update(SERVER_NAME="example.com:8080")253254 @app.route("/")255 def index():256 flask.session["testing"] = 42257 return "Hello World"258259 rv = client.get("/", "http://example.com:8080/")260 assert "domain=.example.com" in rv.headers["set-cookie"].lower()261 assert "httponly" in rv.headers["set-cookie"].lower()262263Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 264why, one step back264def test_session_using_server_name_port_and_path(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 265–277why, one step back265 app.config.update(SERVER_NAME="example.com:8080", APPLICATION_ROOT="/foo")266267 @app.route("/")268 def index():269 flask.session["testing"] = 42270 return "Hello World"271272 rv = client.get("/", "http://example.com:8080/foo")273 assert "domain=example.com" in rv.headers["set-cookie"].lower()274 assert "path=/foo" in rv.headers["set-cookie"].lower()275 assert "httponly" in rv.headers["set-cookie"].lower()276277Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 278why, one step back278def test_session_using_application_root(app, client):Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 279why, one step back279 class PrefixPathMiddleware:Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 280–282why, one step back280 def __init__(self, app, prefix):281 self.app = app282 self.prefix = prefixMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 283why, one step back283Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 284why, one step back284 def __call__(self, environ, start_response):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 285why, one step back285 environ["SCRIPT_NAME"] = self.prefixMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 286why, one step back286 return self.app(environ, start_response)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 287–299why, one step back287288 app.wsgi_app = PrefixPathMiddleware(app.wsgi_app, "/bar")289 app.config.update(APPLICATION_ROOT="/bar")290291 @app.route("/")292 def index():293 flask.session["testing"] = 42294 return "Hello World"295296 rv = client.get("/", "http://example.com:8080/")297 assert "path=/bar" in rv.headers["set-cookie"].lower()298299Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 300why, one step back300def test_session_using_session_settings(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 301–304why, one step back301 app.config.update(302 SERVER_NAME="www.example.com:8080",303 APPLICATION_ROOT="/test",304 SESSION_COOKIE_DOMAIN=".example.com",Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 305–306why, one step back305 SESSION_COOKIE_HTTPONLY=False,306 SESSION_COOKIE_SECURE=True,Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 307–324why, one step back307 SESSION_COOKIE_SAMESITE="Lax",308 SESSION_COOKIE_PATH="/",309 )310311 @app.route("/")312 def index():313 flask.session["testing"] = 42314 return "Hello World"315316 rv = client.get("/", "http://www.example.com:8080/test/")317 cookie = rv.headers["set-cookie"].lower()318 assert "domain=.example.com" in cookie319 assert "path=/" in cookie320 assert "secure" in cookie321 assert "httponly" not in cookie322 assert "samesite" in cookie323324Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 325why, one step back325def test_session_using_samesite_attribute(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 326–332why, one step back326 @app.route("/")327 def index():328 flask.session["testing"] = 42329 return "Hello World"330331 app.config.update(SESSION_COOKIE_SAMESITE="invalid")332Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 333why, one step back333 with pytest.raises(ValueError):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 334–335why, one step back334 client.get("/")335Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 336why, one step back336 app.config.update(SESSION_COOKIE_SAMESITE=None)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 337–351why, one step back337 rv = client.get("/")338 cookie = rv.headers["set-cookie"].lower()339 assert "samesite" not in cookie340341 app.config.update(SESSION_COOKIE_SAMESITE="Strict")342 rv = client.get("/")343 cookie = rv.headers["set-cookie"].lower()344 assert "samesite=strict" in cookie345346 app.config.update(SESSION_COOKIE_SAMESITE="Lax")347 rv = client.get("/")348 cookie = rv.headers["set-cookie"].lower()349 assert "samesite=lax" in cookie350351Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 352why, one step back352def test_session_localhost_warning(recwarn, app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 353–362why, one step back353 app.config.update(SERVER_NAME="localhost:5000")354355 @app.route("/")356 def index():357 flask.session["testing"] = 42358 return "testing"359360 rv = client.get("/", "http://localhost:5000/")361 assert "domain" not in rv.headers["set-cookie"].lower()362 w = recwarn.pop(UserWarning)Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 363why, one step back363 assert "'localhost' is not a valid cookie domain" in str(w.message)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 364–365why, one step back364365Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 366why, one step back366def test_session_ip_warning(recwarn, app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 367–379why, one step back367 app.config.update(SERVER_NAME="127.0.0.1:5000")368369 @app.route("/")370 def index():371 flask.session["testing"] = 42372 return "testing"373374 rv = client.get("/", "http://127.0.0.1:5000/")375 assert "domain=127.0.0.1" in rv.headers["set-cookie"].lower()376 w = recwarn.pop(UserWarning)377 assert "cookie domain is an IP" in str(w.message)378379Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 380–381why, one step back380def test_missing_session(app):381 app.secret_key = NoneMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 382why, one step back382Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 383–384why, one step back383 def expect_exception(f, *args, **kwargs):384 e = pytest.raises(RuntimeError, f, *args, **kwargs)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 385–392why, one step back385 assert e.value.args and "session is unavailable" in e.value.args[0]386387 with app.test_request_context():388 assert flask.session.get("missing_key") is None389 expect_exception(flask.session.__setitem__, "foo", 42)390 expect_exception(flask.session.pop, "foo")391392Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 393–394why, one step back393def test_session_expiration(app, client):394 permanent = TrueMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 395–398why, one step back395396 @app.route("/")397 def index():398 flask.session["test"] = 42Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 399why, one step back399 flask.session.permanent = permanentMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 400–403why, one step back400 return ""401402 @app.route("/test")403 def test():Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 404why, one step back404 return str(flask.session.permanent)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 405–408why, one step back405406 rv = client.get("/")407 assert "set-cookie" in rv.headers408 match = re.search(r"(?i)\bexpires=([^;]+)", rv.headers["set-cookie"])Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 409–413why, one step back409 expires = parse_date(match.group())410 expected = datetime.utcnow() + app.permanent_session_lifetime411 assert expires.year == expected.year412 assert expires.month == expected.month413 assert expires.day == expected.dayMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 414–417why, one step back414415 rv = client.get("/test")416 assert rv.data == b"True"417Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 418why, one step back418 permanent = FalseMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 419–421why, one step back419 rv = client.get("/")420 assert "set-cookie" in rv.headers421 match = re.search(r"\bexpires=([^;]+)", rv.headers["set-cookie"])Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 422why, one step back422 assert match is NoneMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 423–424why, one step back423424Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 425why, one step back425def test_session_stored_last(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 426why, one step back426 @app.after_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 427why, one step back427 def modify_session(response):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 428–438why, one step back428 flask.session["foo"] = 42429 return response430431 @app.route("/")432 def dump_session_contents():433 return repr(flask.session.get("foo"))434435 assert client.get("/").data == b"None"436 assert client.get("/").data == b"42"437438Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 439–441why, one step back439def test_session_special_types(app, client):440 now = datetime.utcnow().replace(microsecond=0)441 the_uuid = uuid.uuid4()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 442–456why, one step back442443 @app.route("/")444 def dump_session_contents():445 flask.session["t"] = (1, 2, 3)446 flask.session["b"] = b"\xff"447 flask.session["m"] = flask.Markup("<html>")448 flask.session["u"] = the_uuid449 flask.session["d"] = now450 flask.session["t_tag"] = {" t": "not-a-tuple"}451 flask.session["di_t_tag"] = {" t__": "not-a-tuple"}452 flask.session["di_tag"] = {" di": "not-a-dict"}453 return "", 204454455 with client:456 client.get("/")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 457why, one step back457 s = flask.sessionMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 458–469why, one step back458 assert s["t"] == (1, 2, 3)459 assert type(s["b"]) == bytes460 assert s["b"] == b"\xff"461 assert type(s["m"]) == flask.Markup462 assert s["m"] == flask.Markup("<html>")463 assert s["u"] == the_uuid464 assert s["d"] == now465 assert s["t_tag"] == {" t": "not-a-tuple"}466 assert s["di_t_tag"] == {" t__": "not-a-tuple"}467 assert s["di_tag"] == {" di": "not-a-dict"}468469Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 470why, one step back470def test_session_cookie_setting(app):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 471–473why, one step back471 is_permanent = True472473 @app.route("/bump")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 474why, one step back474 def bump():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 475why, one step back475 rv = flask.session["foo"] = flask.session.get("foo", 0) + 1Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 476–477why, one step back476 flask.session.permanent = is_permanent477 return str(rv)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 478–479why, one step back478479 @app.route("/read")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 480why, one step back480 def read():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 481–482why, one step back481 return str(flask.session.get("foo", 0))482Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 483–484why, one step back483 def run_test(expect_header):484 with app.test_client() as c:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 485–490why, one step back485 assert c.get("/bump").data == b"1"486 assert c.get("/bump").data == b"2"487 assert c.get("/bump").data == b"3"488489 rv = c.get("/read")490 set_cookie = rv.headers.get("set-cookie")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 491why, one step back491 assert (set_cookie is not None) == expect_headerMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 492–495why, one step back492 assert rv.data == b"3"493494 is_permanent = True495 app.config["SESSION_REFRESH_EACH_REQUEST"] = TrueMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 496why, one step back496 run_test(expect_header=True)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 497–510why, one step back497498 is_permanent = True499 app.config["SESSION_REFRESH_EACH_REQUEST"] = False500 run_test(expect_header=False)501502 is_permanent = False503 app.config["SESSION_REFRESH_EACH_REQUEST"] = True504 run_test(expect_header=False)505506 is_permanent = False507 app.config["SESSION_REFRESH_EACH_REQUEST"] = False508 run_test(expect_header=False)509510Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 511why, one step back511def test_session_vary_cookie(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 512why, one step back512 @app.route("/set")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 513why, one step back513 def set_session():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 514–521why, one step back514 flask.session["test"] = "test"515 return ""516517 @app.route("/get")518 def get():519 return flask.session.get("test")520521 @app.route("/getitem")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 522why, one step back522 def getitem():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 523–525why, one step back523 return flask.session["test"]524525 @app.route("/setdefault")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 526why, one step back526 def setdefault():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 527–529why, one step back527 return flask.session.setdefault("test", "default")528529 @app.route("/vary-cookie-header-set")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 530why, one step back530 def vary_cookie_header_set():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 531–536why, one step back531 response = flask.Response()532 response.vary.add("Cookie")533 flask.session["test"] = "test"534 return response535536 @app.route("/vary-header-set")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 537why, one step back537 def vary_header_set():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 538–543why, one step back538 response = flask.Response()539 response.vary.update(("Accept-Encoding", "Accept-Language"))540 flask.session["test"] = "test"541 return response542543 @app.route("/no-vary-header")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 544why, one step back544 def no_vary_header():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 545–547why, one step back545 return ""546547 def expect(path, header_value="Cookie"):Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 548why, one step back548 rv = client.get(path)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 549why, one step back549Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 550–551why, one step back550 if header_value:551 # The 'Vary' key should exist in the headers only once.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 552–565why, one step back552 assert len(rv.headers.get_all("Vary")) == 1553 assert rv.headers["Vary"] == header_value554 else:555 assert "Vary" not in rv.headers556557 expect("/set")558 expect("/get")559 expect("/getitem")560 expect("/setdefault")561 expect("/vary-cookie-header-set")562 expect("/vary-header-set", "Accept-Encoding, Accept-Language, Cookie")563 expect("/no-vary-header", None)564565Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 566–567why, one step back566def test_flashes(app, req_ctx):567 assert not flask.session.modifiedMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 568why, one step back568 flask.flash("Zap")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 569why, one step back569 flask.session.modified = FalseMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 570why, one step back570 flask.flash("Zip")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 571why, one step back571 assert flask.session.modifiedMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 572–574why, one step back572 assert list(flask.get_flashed_messages()) == ["Zap", "Zip"]573574Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 575–580why, one step back575def test_extended_flashing(app):576 # Be sure app.testing=True below, else tests can fail silently.577 #578 # Specifically, if app.testing is not set to True, the AssertionErrors579 # in the view functions will cause a 500 response to the test client580 # instead of propagating exceptions.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 581–583why, one step back581582 @app.route("/")583 def index():Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
lines 584–586why, one step back584 flask.flash("Hello World")585 flask.flash("Hello World", "error")586 flask.flash(flask.Markup("<em>Testing</em>"), "warning")Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 587–590why, one step back587 return ""588589 @app.route("/test/")590 def test():Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 591why, one step back591 messages = flask.get_flashed_messages()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 592why, one step back592 assert list(messages) == [Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
lines 593–595why, one step back593 "Hello World",594 "Hello World",595 flask.Markup("<em>Testing</em>"),Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 596–599why, one step back596 ]597 return ""598599 @app.route("/test_with_categories/")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 600–602why, one step back600 def test_with_categories():601 messages = flask.get_flashed_messages(with_categories=True)602 assert len(messages) == 3Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 603why, one step back603 assert list(messages) == [Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
lines 604–606why, one step back604 ("message", "Hello World"),605 ("error", "Hello World"),606 ("warning", flask.Markup("<em>Testing</em>")),Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 607–610why, one step back607 ]608 return ""609610 @app.route("/test_filter/")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 611why, one step back611 def test_filter():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 612–614why, one step back612 messages = flask.get_flashed_messages(613 category_filter=["message"], with_categories=True614 )Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 615why, one step back615 assert list(messages) == [("message", "Hello World")]Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 616–618why, one step back616 return ""617618 @app.route("/test_filters/")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 619why, one step back619 def test_filters():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 620–623why, one step back620 messages = flask.get_flashed_messages(621 category_filter=["message", "warning"], with_categories=True622 )623 assert list(messages) == [Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
lines 624–625why, one step back624 ("message", "Hello World"),625 ("warning", flask.Markup("<em>Testing</em>")),Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 626–629why, one step back626 ]627 return ""628629 @app.route("/test_filters_without_returning_categories/")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 630why, one step back630 def test_filters2():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 631why, one step back631 messages = flask.get_flashed_messages(category_filter=["message", "warning"])Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 632why, one step back632 assert len(messages) == 2Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
lines 633–634why, one step back633 assert messages[0] == "Hello World"634 assert messages[1] == flask.Markup("<em>Testing</em>")Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 635–636why, one step back635 return ""636Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 637why, one step back637 # Create new test client on each test to clean flashed messages.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 638–655why, one step back638639 client = app.test_client()640 client.get("/")641 client.get("/test_with_categories/")642643 client = app.test_client()644 client.get("/")645 client.get("/test_filter/")646647 client = app.test_client()648 client.get("/")649 client.get("/test_filters/")650651 client = app.test_client()652 client.get("/")653 client.get("/test_filters_without_returning_categories/")654655Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 656why, one step back656def test_request_processing(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 657–680why, one step back657 evts = []658659 @app.before_request660 def before_request():661 evts.append("before")662663 @app.after_request664 def after_request(response):665 response.data += b"|after"666 evts.append("after")667 return response668669 @app.route("/")670 def index():671 assert "before" in evts672 assert "after" not in evts673 return "request"674675 assert "after" not in evts676 rv = client.get("/").data677 assert "after" in evts678 assert rv == b"request|after"679680Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 681why, one step back681def test_request_preprocessing_early_return(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 682–684why, one step back682 evts = []683684 @app.before_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 685–686why, one step back685 def before_request1():686 evts.append(1)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 687–688why, one step back687688 @app.before_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 689–691why, one step back689 def before_request2():690 evts.append(2)691 return "hello"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 692–693why, one step back692693 @app.before_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 694–696why, one step back694 def before_request3():695 evts.append(3)696 return "bye"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 697–700why, one step back697698 @app.route("/")699 def index():700 evts.append("index")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 701why, one step back701 return "damnit"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 702–704why, one step back702703 rv = client.get("/").data.strip()704 assert rv == b"hello"Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 705why, one step back705 assert evts == [1, 2]Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 706–707why, one step back706707Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 708why, one step back708def test_after_request_processing(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 709–710why, one step back709 @app.route("/")710 def index():Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 711–712why, one step back711 @flask.after_this_request712 def foo(response):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 713why, one step back713 response.headers["X-Foo"] = "a header"Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 714why, one step back714 return responseMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 715–718why, one step back715716 return "Test"717718 resp = client.get("/")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 719why, one step back719 assert resp.status_code == 200Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 720–722why, one step back720 assert resp.headers["X-Foo"] == "a header"721722Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 723why, one step back723def test_teardown_request_handler(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 724–740why, one step back724 called = []725726 @app.teardown_request727 def teardown_request(exc):728 called.append(True)729 return "Ignored"730731 @app.route("/")732 def root():733 return "Response"734735 rv = client.get("/")736 assert rv.status_code == 200737 assert b"Response" in rv.data738 assert len(called) == 1739740Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 741why, one step back741def test_teardown_request_handler_debug_mode(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 742–758why, one step back742 called = []743744 @app.teardown_request745 def teardown_request(exc):746 called.append(True)747 return "Ignored"748749 @app.route("/")750 def root():751 return "Response"752753 rv = client.get("/")754 assert rv.status_code == 200755 assert b"Response" in rv.data756 assert len(called) == 1757758Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 759why, one step back759def test_teardown_request_handler_error(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 760–763why, one step back760 called = []761 app.testing = False762763 @app.teardown_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 764why, one step back764 def teardown_request1(exc):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 765–771why, one step back765 assert type(exc) == ZeroDivisionError766 called.append(True)767 # This raises a new error and blows away sys.exc_info(), so we can768 # test that all teardown_requests get passed the same original769 # exception.770 try:771 raise TypeError()Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86
line 772why, one step back772 except Exception:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 773–775why, one step back773 pass774775 @app.teardown_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 776why, one step back776 def teardown_request2(exc):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 777–783why, one step back777 assert type(exc) == ZeroDivisionError778 called.append(True)779 # This raises a new error and blows away sys.exc_info(), so we can780 # test that all teardown_requests get passed the same original781 # exception.782 try:783 raise TypeError()Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86
line 784why, one step back784 except Exception:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 785–787why, one step back785 pass786787 @app.route("/")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 788why, one step back788 def fails():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 789–793why, one step back789 1 // 0790791 rv = client.get("/")792 assert rv.status_code == 500793 assert b"Internal Server Error" in rv.dataMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 794why, one step back794 assert len(called) == 2Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 795–796why, one step back795796Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 797why, one step back797def test_before_after_request_order(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 798–800why, one step back798 called = []799800 @app.before_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 801–802why, one step back801 def before1():802 called.append(1)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 803–804why, one step back803804 @app.before_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 805–806why, one step back805 def before2():806 called.append(2)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 807–808why, one step back807808 @app.after_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 809–810why, one step back809 def after1(response):810 called.append(4)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 811–813why, one step back811 return response812813 @app.after_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 814–815why, one step back814 def after2(response):815 called.append(3)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 816–818why, one step back816 return response817818 @app.teardown_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 819–820why, one step back819 def finish1(exc):820 called.append(6)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 821–822why, one step back821822 @app.teardown_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 823–824why, one step back823 def finish2(exc):824 called.append(5)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 825–831why, one step back825826 @app.route("/")827 def index():828 return "42"829830 rv = client.get("/")831 assert rv.data == b"42"Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 832why, one step back832 assert called == [1, 2, 3, 4, 5, 6]Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 833–834why, one step back833834Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 835why, one step back835def test_error_handling(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 836–838why, one step back836 app.testing = False837838 @app.errorhandler(404)Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 839why, one step back839 def not_found(e):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 840–845why, one step back840 return "not found", 404841842 @app.errorhandler(500)843 def internal_server_error(e):844 return "internal server error", 500845Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 846–847why, one step back846 @app.errorhandler(Forbidden)847 def forbidden(e):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 848–854why, one step back848 return "forbidden", 403849850 @app.route("/")851 def index():852 flask.abort(404)853854 @app.route("/error")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 855why, one step back855 def error():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 856–858why, one step back856 1 // 0857858 @app.route("/forbidden")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 859why, one step back859 def error2():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 860–868why, one step back860 flask.abort(403)861862 rv = client.get("/")863 assert rv.status_code == 404864 assert rv.data == b"not found"865 rv = client.get("/error")866 assert rv.status_code == 500867 assert b"internal server error" == rv.data868 rv = client.get("/forbidden")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 869why, one step back869 assert rv.status_code == 403Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 870–872why, one step back870 assert b"forbidden" == rv.data871872Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 873–874why, one step back873def test_error_handler_unknown_code(app):874 with pytest.raises(KeyError) as exc_info:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 875–879why, one step back875 app.register_error_handler(999, lambda e: ("999", 999))876877 assert "Use a subclass" in exc_info.value.args[0]878879Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 880why, one step back880def test_error_handling_processing(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 881–891why, one step back881 app.testing = False882883 @app.errorhandler(500)884 def internal_server_error(e):885 return "internal server error", 500886887 @app.route("/")888 def broken_func():889 1 // 0890891 @app.after_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 892why, one step back892 def after_request(resp):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 893why, one step back893 resp.mimetype = "text/x-special"Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 894why, one step back894 return respMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 895–900why, one step back895896 resp = client.get("/")897 assert resp.mimetype == "text/x-special"898 assert resp.data == b"internal server error"899900Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 901why, one step back901def test_baseexception_error_handling(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 902–905why, one step back902 app.testing = False903904 @app.route("/")905 def broken_func():Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 906why, one step back906 raise KeyboardInterrupt()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 907why, one step back907Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 908why, one step back908 with pytest.raises(KeyboardInterrupt):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 909–910why, one step back909 client.get("/")910Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 911–913why, one step back911 ctx = flask._request_ctx_stack.top912 assert ctx.preserved913 assert type(ctx._preserved_exc) is KeyboardInterruptMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 914–915why, one step back914915Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 916why, one step back916def test_before_request_and_routing_errors(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 917why, one step back917 @app.before_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 918why, one step back918 def attach_something():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 919–921why, one step back919 flask.g.something = "value"920921 @app.errorhandler(404)Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 922–923why, one step back922 def return_something(error):923 return flask.g.something, 404Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 924–929why, one step back924925 rv = client.get("/")926 assert rv.status_code == 404927 assert rv.data == b"value"928929Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 930–931why, one step back930def test_user_error_handling(app, client):931 class MyException(Exception):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 932–933why, one step back932 pass933Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 934–936why, one step back934 @app.errorhandler(MyException)935 def handle_my_exception(e):936 assert isinstance(e, MyException)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 937–940why, one step back937 return "42"938939 @app.route("/")940 def index():Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 941why, one step back941 raise MyException()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 942–945why, one step back942943 assert client.get("/").data == b"42"944945Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 946–947why, one step back946def test_http_error_subclass_handling(app, client):947 class ForbiddenSubclass(Forbidden):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 948–949why, one step back948 pass949Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 950why, one step back950 @app.errorhandler(ForbiddenSubclass)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 951why, one step back951 def handle_forbidden_subclass(e):Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 952why, one step back952 assert isinstance(e, ForbiddenSubclass)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 953–954why, one step back953 return "banana"954Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 955why, one step back955 @app.errorhandler(403)Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86
line 956why, one step back956 def handle_403(e):Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 957–958why, one step back957 assert not isinstance(e, ForbiddenSubclass)958 assert isinstance(e, Forbidden)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 959–961why, one step back959 return "apple"960961 @app.route("/1")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 962–963why, one step back962 def index1():963 raise ForbiddenSubclass()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 964–969why, one step back964965 @app.route("/2")966 def index2():967 flask.abort(403)968969 @app.route("/3")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 970–971why, one step back970 def index3():971 raise Forbidden()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 972–977why, one step back972973 assert client.get("/1").data == b"banana"974 assert client.get("/2").data == b"apple"975 assert client.get("/3").data == b"apple"976977Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 978–979why, one step back978def test_errorhandler_precedence(app, client):979 class E1(Exception):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 980–981why, one step back980 pass981Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 982why, one step back982 class E2(Exception):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 983–984why, one step back983 pass984Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 985why, one step back985 class E3(E1, E2):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 986–987why, one step back986 pass987Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 988–989why, one step back988 @app.errorhandler(E2)989 def handle_e2(e):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 990–991why, one step back990 return "E2"991Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 992–993why, one step back992 @app.errorhandler(Exception)993 def handle_exception(e):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 994–996why, one step back994 return "Exception"995996 @app.route("/E1")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 997–998why, one step back997 def raise_e1():998 raise E1Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 999–1000why, one step back9991000 @app.route("/E3")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1001–1002why, one step back1001 def raise_e3():1002 raise E3Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1003–1010why, one step back10031004 rv = client.get("/E1")1005 assert rv.data == b"Exception"10061007 rv = client.get("/E3")1008 assert rv.data == b"E2"10091010Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1011why, one step back1011def test_trapping_of_bad_request_key_errors(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1012–1016why, one step back1012 @app.route("/key")1013 def fail():1014 flask.request.form["missing_key"]10151016 @app.route("/abort")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1017–1018why, one step back1017 def allow_abort():1018 flask.abort(400)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1019–1026why, one step back10191020 rv = client.get("/key")1021 assert rv.status_code == 4001022 assert b"missing_key" not in rv.data1023 rv = client.get("/abort")1024 assert rv.status_code == 40010251026 app.debug = TrueMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1027why, one step back1027 with pytest.raises(KeyError) as e:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1028why, one step back1028 client.get("/key")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1029why, one step back1029 assert e.errisinstance(BadRequest)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1030–1035why, one step back1030 assert "missing_key" in e.value.get_description()1031 rv = client.get("/abort")1032 assert rv.status_code == 40010331034 app.debug = False1035 app.config["TRAP_BAD_REQUEST_ERRORS"] = TrueMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1036why, one step back1036 with pytest.raises(KeyError):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1037why, one step back1037 client.get("/key")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1038why, one step back1038 with pytest.raises(BadRequest):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1039–1041why, one step back1039 client.get("/abort")10401041Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1042why, one step back1042def test_trapping_of_all_http_exceptions(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1043–1048why, one step back1043 app.config["TRAP_HTTP_EXCEPTIONS"] = True10441045 @app.route("/fail")1046 def fail():1047 flask.abort(404)1048Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1049why, one step back1049 with pytest.raises(NotFound):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1050–1052why, one step back1050 client.get("/fail")10511052Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1053why, one step back1053def test_error_handler_after_processor_error(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1054–1057why, one step back1054 app.testing = False10551056 @app.before_request1057 def before_request():Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86
line 1058why, one step back1058 if _trigger == "before":Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1059–1062why, one step back1059 1 // 010601061 @app.after_request1062 def after_request(response):Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86
line 1063why, one step back1063 if _trigger == "after":Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1064–1074why, one step back1064 1 // 01065 return response10661067 @app.route("/")1068 def index():1069 return "Foo"10701071 @app.errorhandler(500)1072 def internal_server_error(e):1073 return "Hello Server Error", 5001074Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86
line 1075why, one step back1075 for _trigger in "before", "after":Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1076why, one step back1076 rv = client.get("/")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1077why, one step back1077 assert rv.status_code == 500Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1078–1080why, one step back1078 assert rv.data == b"Hello Server Error"10791080Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1081–1082why, one step back1081def test_enctype_debug_helper(app, client):1082 from flask.debughelpers import DebugFilesKeyErrorMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1083–1089why, one step back10831084 app.debug = True10851086 @app.route("/fail", methods=["POST"])1087 def index():1088 return flask.request.files["foo"].filename1089Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1090–1092why, one step back1090 # with statement is important because we leave an exception on the1091 # stack otherwise and we want to ensure that this is not the case1092 # to not negatively affect other tests.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1093why, one step back1093 with client:Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1094why, one step back1094 with pytest.raises(DebugFilesKeyError) as e:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1095–1096why, one step back1095 client.post("/fail", data={"foo": "index.txt"})1096 assert "no file contents were transmitted" in str(e.value)Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 1097why, one step back1097 assert "This was submitted: 'index.txt'" in str(e.value)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1098–1099why, one step back10981099Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1100why, one step back1100def test_response_types(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1101why, one step back1101 @app.route("/text")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1102why, one step back1102 def from_text():Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 1103why, one step back1103 return "Hällo Wörld"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1104–1105why, one step back11041105 @app.route("/bytes")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1106why, one step back1106 def from_bytes():Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 1107why, one step back1107 return "Hällo Wörld".encode()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1108–1109why, one step back11081109 @app.route("/full_tuple")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1110why, one step back1110 def from_full_tuple():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1111–1117why, one step back1111 return (1112 "Meh",1113 400,1114 {"X-Foo": "Testing", "Content-Type": "text/plain; charset=utf-8"},1115 )11161117 @app.route("/text_headers")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1118why, one step back1118 def from_text_headers():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1119–1121why, one step back1119 return "Hello", {"X-Foo": "Test", "Content-Type": "text/plain; charset=utf-8"}11201121 @app.route("/text_status")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1122why, one step back1122 def from_text_status():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1123–1125why, one step back1123 return "Hi, status!", 40011241125 @app.route("/response_headers")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1126why, one step back1126 def from_response_headers():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1127why, one step back1127 return (Merge pull request #3684 from MLH-Fellowship/3628-duplicate-headersDavid Lordbefore adoption2fa8eb3
lines 1128–1131why, one step back1128 flask.Response(1129 "Hello world", 404, {"Content-Type": "text/html", "X-Foo": "Baz"}1130 ),1131 {"Content-Type": "text/plain", "X-Foo": "Bar", "X-Bar": "Foo"},Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1132–1134why, one step back1132 )11331134 @app.route("/response_status")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1135why, one step back1135 def from_response_status():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1136–1138why, one step back1136 return app.response_class("Hello world", 400), 50011371138 @app.route("/wsgi")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1139–1140why, one step back1139 def from_wsgi():1140 return NotFound()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1141why, one step back1141Merge pull request #3229 from lordmauve/style-fixDavid Lordbefore adoption240e398
line 1142why, one step back1142 @app.route("/dict")Merge pull request #3111 from pgjones/masterDavid Lordbefore adoption855d59b
lines 1143–1144why, one step back1143 def from_dict():1144 return {"foo": "bar"}, 201Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1145why, one step back1145Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
lines 1146–1147why, one step back1146 assert client.get("/text").data == "Hällo Wörld".encode()1147 assert client.get("/bytes").data == "Hällo Wörld".encode()Merge pull request #3111 from pgjones/masterDavid Lordbefore adoption855d59b
line 1148why, one step back1148Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1149–1167why, one step back1149 rv = client.get("/full_tuple")1150 assert rv.data == b"Meh"1151 assert rv.headers["X-Foo"] == "Testing"1152 assert rv.status_code == 4001153 assert rv.mimetype == "text/plain"11541155 rv = client.get("/text_headers")1156 assert rv.data == b"Hello"1157 assert rv.headers["X-Foo"] == "Test"1158 assert rv.status_code == 2001159 assert rv.mimetype == "text/plain"11601161 rv = client.get("/text_status")1162 assert rv.data == b"Hi, status!"1163 assert rv.status_code == 4001164 assert rv.mimetype == "text/html"11651166 rv = client.get("/response_headers")1167 assert rv.data == b"Hello world"Merge pull request #3684 from MLH-Fellowship/3628-duplicate-headersDavid Lordbefore adoption2fa8eb3
lines 1168–1169why, one step back1168 assert rv.content_type == "text/plain"1169 assert rv.headers.getlist("X-Foo") == ["Bar"]Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1170–1179why, one step back1170 assert rv.headers["X-Bar"] == "Foo"1171 assert rv.status_code == 40411721173 rv = client.get("/response_status")1174 assert rv.data == b"Hello world"1175 assert rv.status_code == 50011761177 rv = client.get("/wsgi")1178 assert b"Not Found" in rv.data1179 assert rv.status_code == 404Merge pull request #3111 from pgjones/masterDavid Lordbefore adoption855d59b
line 1180why, one step back1180Merge pull request #3229 from lordmauve/style-fixDavid Lordbefore adoption240e398
line 1181why, one step back1181 rv = client.get("/dict")Merge pull request #3111 from pgjones/masterDavid Lordbefore adoption855d59b
lines 1182–1183why, one step back1182 assert rv.json == {"foo": "bar"}1183 assert rv.status_code == 201Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1184–1185why, one step back11841185Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1186why, one step back1186def test_response_type_errors():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1187–1190why, one step back1187 app = flask.Flask(__name__)1188 app.testing = True11891190 @app.route("/none")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1191why, one step back1191 def from_none():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1192–1194why, one step back1192 pass11931194 @app.route("/small_tuple")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1195why, one step back1195 def from_small_tuple():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1196–1198why, one step back1196 return ("Hello",)11971198 @app.route("/large_tuple")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1199why, one step back1199 def from_large_tuple():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1200–1202why, one step back1200 return "Hello", 234, {"X-Foo": "Bar"}, "???"12011202 @app.route("/bad_type")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1203–1204why, one step back1203 def from_bad_type():1204 return TrueMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1205–1206why, one step back12051206 @app.route("/bad_wsgi")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1207–1208why, one step back1207 def from_bad_wsgi():1208 return lambda: NoneMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1209–1213why, one step back12091210 c = app.test_client()12111212 with pytest.raises(TypeError) as e:1213 c.get("/none")Merge branch '1.0.x'David Lordbefore adoptionb05a685
line 1214why, one step back1214 assert "returned None" in str(e.value)Merge pull request #3498 from raymond-devries/3445-traceback-for-noneDavid Lordbefore adoptiona3e4395
line 1215why, one step back1215 assert "from_none" in str(e.value)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1216–1218why, one step back12161217 with pytest.raises(TypeError) as e:1218 c.get("/small_tuple")Merge branch '1.0.x'David Lordbefore adoptionb05a685
line 1219why, one step back1219 assert "tuple must have the form" in str(e.value)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1220–1224why, one step back12201221 pytest.raises(TypeError, c.get, "/large_tuple")12221223 with pytest.raises(TypeError) as e:1224 c.get("/bad_type")Merge branch '1.0.x'David Lordbefore adoptionb05a685
line 1225why, one step back1225 assert "it was a bool" in str(e.value)Merge pull request #3235 from johnzeringue/better-return-type-errorDavid Lordbefore adoption52f9aa7
line 1226why, one step back1226Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1227–1229why, one step back1227 pytest.raises(TypeError, c.get, "/bad_wsgi")12281229Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1230–1231why, one step back1230def test_make_response(app, req_ctx):1231 rv = flask.make_response()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1232–1246why, one step back1232 assert rv.status_code == 2001233 assert rv.data == b""1234 assert rv.mimetype == "text/html"12351236 rv = flask.make_response("Awesome")1237 assert rv.status_code == 2001238 assert rv.data == b"Awesome"1239 assert rv.mimetype == "text/html"12401241 rv = flask.make_response("W00t", 404)1242 assert rv.status_code == 4041243 assert rv.data == b"W00t"1244 assert rv.mimetype == "text/html"12451246Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1247why, one step back1247def test_make_response_with_response_instance(app, req_ctx):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1248–1249why, one step back1248 rv = flask.make_response(flask.jsonify({"msg": "W00t"}), 400)1249 assert rv.status_code == 400Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1250why, one step back1250 assert rv.data == b'{"msg":"W00t"}\n'Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1251–1267why, one step back1251 assert rv.mimetype == "application/json"12521253 rv = flask.make_response(flask.Response(""), 400)1254 assert rv.status_code == 4001255 assert rv.data == b""1256 assert rv.mimetype == "text/html"12571258 rv = flask.make_response(1259 flask.Response("", headers={"Content-Type": "text/html"}),1260 400,1261 [("X-Foo", "bar")],1262 )1263 assert rv.status_code == 4001264 assert rv.headers["Content-Type"] == "text/html"1265 assert rv.headers["X-Foo"] == "bar"12661267Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1268–1270why, one step back1268def test_jsonify_no_prettyprint(app, req_ctx):1269 app.config.update({"JSONIFY_PRETTYPRINT_REGULAR": False})1270 compressed_msg = b'{"msg":{"submsg":"W00t"},"msg2":"foobar"}\n'Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1271–1273why, one step back1271 uncompressed_msg = {"msg": {"submsg": "W00t"}, "msg2": "foobar"}12721273 rv = flask.make_response(flask.jsonify(uncompressed_msg), 200)Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1274why, one step back1274 assert rv.data == compressed_msgMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1275–1276why, one step back12751276Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1277–1279why, one step back1277def test_jsonify_prettyprint(app, req_ctx):1278 app.config.update({"JSONIFY_PRETTYPRINT_REGULAR": True})1279 compressed_msg = {"msg": {"submsg": "W00t"}, "msg2": "foobar"}Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1280why, one step back1280 pretty_response = (Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1281why, one step back1281 b'{\n "msg": {\n "submsg": "W00t"\n }, \n "msg2": "foobar"\n}\n'Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1282–1284why, one step back1282 )12831284 rv = flask.make_response(flask.jsonify(compressed_msg), 200)Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1285why, one step back1285 assert rv.data == pretty_responseMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1286–1287why, one step back12861287Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1288why, one step back1288def test_jsonify_mimetype(app, req_ctx):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1289–1293why, one step back1289 app.config.update({"JSONIFY_MIMETYPE": "application/vnd.api+json"})1290 msg = {"msg": {"submsg": "W00t"}}1291 rv = flask.make_response(flask.jsonify(msg), 200)1292 assert rv.mimetype == "application/vnd.api+json"1293Merge pull request #3195 from eruvanos/json_support_dataclassDavid Lordbefore adoptionb0185a6
lines 1294–1297why, one step back12941295@pytest.mark.skipif(sys.version_info < (3, 7), reason="requires Python >= 3.7")1296def test_json_dump_dataclass(app, req_ctx):1297 from dataclasses import make_dataclassMerge pull request #3229 from lordmauve/style-fixDavid Lordbefore adoption240e398
line 1298why, one step back1298Merge pull request #3195 from eruvanos/json_support_dataclassDavid Lordbefore adoptionb0185a6
lines 1299–1302why, one step back1299 Data = make_dataclass("Data", [("name", str)])1300 value = flask.json.dumps(Data("Flask"), app=app)1301 value = flask.json.loads(value, app=app)1302 assert value == {"name": "Flask"}Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1303why, one step back1303Merge pull request #3229 from lordmauve/style-fixDavid Lordbefore adoption240e398
line 1304why, one step back1304Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1305why, one step back1305def test_jsonify_args_and_kwargs_check(app, req_ctx):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1306–1310why, one step back1306 with pytest.raises(TypeError) as e:1307 flask.jsonify("fake args", kwargs="fake")1308 assert "behavior undefined" in str(e.value)13091310Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1311why, one step back1311def test_url_generation(app, req_ctx):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1312why, one step back1312 @app.route("/hello/<name>", methods=["POST"])Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1313why, one step back1313 def hello():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1314–1322why, one step back1314 pass13151316 assert flask.url_for("hello", name="test x") == "/hello/test%20x"1317 assert (1318 flask.url_for("hello", name="test x", _external=True)1319 == "http://localhost/hello/test%20x"1320 )13211322Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1323–1324why, one step back1323def test_build_error_handler(app):1324 # Test base case, a URL which results in a BuildError.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1325–1327why, one step back1325 with app.test_request_context():1326 pytest.raises(BuildError, flask.url_for, "spam")1327Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1328why, one step back1328 # Verify the error is re-raised if not the current exception.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1329why, one step back1329 try:Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1330why, one step back1330 with app.test_request_context():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1331why, one step back1331 flask.url_for("spam")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1332–1333why, one step back1332 except BuildError as err:1333 error = errMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1334–1335why, one step back1334 try:1335 raise RuntimeError("Test case where BuildError is not current.")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1336why, one step back1336 except RuntimeError:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1337–1338why, one step back1337 pytest.raises(BuildError, app.handle_url_build_error, error, "spam", {})1338Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1339why, one step back1339 # Test a custom handler.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1340why, one step back1340 def handler(error, endpoint, values):Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1341why, one step back1341 # Just a test.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1342–1343why, one step back1342 return "/test_handler/"1343Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1344why, one step back1344 app.url_build_error_handlers.append(handler)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1345–1348why, one step back1345 with app.test_request_context():1346 assert flask.url_for("spam") == "/test_handler/"13471348Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1349–1352why, one step back1349def test_build_error_handler_reraise(app):1350 # Test a custom handler which reraises the BuildError1351 def handler_raises_build_error(error, endpoint, values):1352 raise errorMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1353why, one step back1353Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1354why, one step back1354 app.url_build_error_handlers.append(handler_raises_build_error)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1355–1359why, one step back13551356 with app.test_request_context():1357 pytest.raises(BuildError, flask.url_for, "not.existing")13581359Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1360–1361why, one step back1360def test_url_for_passes_special_values_to_build_error_handler(app):1361 @app.url_build_error_handlers.appendMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1362why, one step back1362 def handler(error, endpoint, values):Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1363why, one step back1363 assert values == {Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1364–1374why, one step back1364 "_external": False,1365 "_anchor": None,1366 "_method": None,1367 "_scheme": None,1368 }1369 return "handled"13701371 with app.test_request_context():1372 flask.url_for("/")13731374Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1375why, one step back1375def test_static_files(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1376–1383why, one step back1376 rv = client.get("/static/index.html")1377 assert rv.status_code == 2001378 assert rv.data.strip() == b"<h1>Hello World!</h1>"1379 with app.test_request_context():1380 assert flask.url_for("static", filename="index.html") == "/static/index.html"1381 rv.close()13821383Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1384why, one step back1384def test_static_url_path():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1385–1394why, one step back1385 app = flask.Flask(__name__, static_url_path="/foo")1386 app.testing = True1387 rv = app.test_client().get("/foo/index.html")1388 assert rv.status_code == 2001389 rv.close()13901391 with app.test_request_context():1392 assert flask.url_for("static", filename="index.html") == "/foo/index.html"13931394Merge pull request #3182 from qil026/issue-3134-url-joinDavid Lordbefore adoptiondbd3840
lines 1395–1405why, one step back1395def test_static_url_path_with_ending_slash():1396 app = flask.Flask(__name__, static_url_path="/foo/")1397 app.testing = True1398 rv = app.test_client().get("/foo/index.html")1399 assert rv.status_code == 2001400 rv.close()14011402 with app.test_request_context():1403 assert flask.url_for("static", filename="index.html") == "/foo/index.html"14041405Merge pull request #3124 from elbeardmorez/fix_static_url_pathDavid Lordbefore adoption754b729
line 1406why, one step back1406def test_static_url_empty_path(app):Merge pull request #3229 from lordmauve/style-fixDavid Lordbefore adoption240e398
lines 1407–1408why, one step back1407 app = flask.Flask(__name__, static_folder="", static_url_path="")1408 rv = app.test_client().open("/static/index.html", method="GET")Merge pull request #3124 from elbeardmorez/fix_static_url_pathDavid Lordbefore adoption754b729
lines 1409–1413why, one step back1409 assert rv.status_code == 2001410 rv.close()141114121413def test_static_url_empty_path_default(app):Merge pull request #3229 from lordmauve/style-fixDavid Lordbefore adoption240e398
lines 1414–1415why, one step back1414 app = flask.Flask(__name__, static_folder="")1415 rv = app.test_client().open("/static/index.html", method="GET")Merge pull request #3124 from elbeardmorez/fix_static_url_pathDavid Lordbefore adoption754b729
lines 1416–1419why, one step back1416 assert rv.status_code == 2001417 rv.close()14181419Merge pull request #3579 from jab/pathlib-for-static_folderJoshua Bronsonbefore adoptioncf5b1d0
lines 1420–1429why, one step back1420@pytest.mark.skipif(sys.version_info < (3, 6), reason="requires Python >= 3.6")1421def test_static_folder_with_pathlib_path(app):1422 from pathlib import Path14231424 app = flask.Flask(__name__, static_folder=Path("static"))1425 rv = app.test_client().open("/static/index.html", method="GET")1426 assert rv.status_code == 2001427 rv.close()14281429Merge remote-tracking branch 'origin/1.1.x'David Lordbefore adoption64ba434
lines 1430–1440why, one step back1430def test_static_folder_with_ending_slash():1431 app = flask.Flask(__name__, static_folder="static/")14321433 @app.route("/<path:path>")1434 def catch_all(path):1435 return path14361437 rv = app.test_client().get("/catch/all")1438 assert rv.data == b"catch/all"14391440Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1441why, one step back1441def test_static_route_with_host_matching():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1442–1449why, one step back1442 app = flask.Flask(__name__, host_matching=True, static_host="example.com")1443 c = app.test_client()1444 rv = c.get("http://example.com/static/index.html")1445 assert rv.status_code == 2001446 rv.close()1447 with app.test_request_context():1448 rv = flask.url_for("static", filename="index.html", _external=True)1449 assert rv == "http://example.com/static/index.html"Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1450why, one step back1450 # Providing static_host without host_matching=True should error.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1451–1452why, one step back1451 with pytest.raises(Exception):1452 flask.Flask(__name__, static_host="example.com")Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86
lines 1453–1454why, one step back1453 # Providing host_matching=True with static_folder1454 # but without static_host should error.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1455why, one step back1455 with pytest.raises(Exception):Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1456why, one step back1456 flask.Flask(__name__, host_matching=True)Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86
lines 1457–1458why, one step back1457 # Providing host_matching=True without static_host1458 # but with static_folder=None should not error.Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1459why, one step back1459 flask.Flask(__name__, host_matching=True, static_folder=None)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1460–1461why, one step back14601461Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1462why, one step back1462def test_request_locals():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1463why, one step back1463 assert repr(flask.g) == "<LocalProxy unbound>"Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1464why, one step back1464 assert not flask.gMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1465–1466why, one step back14651466Merge branch '1.0.x'David Lordbefore adoption29111a3
line 1467why, one step back1467def test_server_name_subdomain():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1468–1472why, one step back1468 app = flask.Flask(__name__, subdomain_matching=True)1469 client = app.test_client()14701471 @app.route("/")1472 def index():Merge branch '1.0.x'David Lordbefore adoption29111a3
line 1473why, one step back1473 return "default"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1474–1475why, one step back14741475 @app.route("/", subdomain="foo")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1476why, one step back1476 def subdomain():Merge branch '1.0.x'David Lordbefore adoption29111a3
line 1477why, one step back1477 return "subdomain"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1478why, one step back1478Merge branch '1.0.x'David Lordbefore adoption29111a3
line 1479why, one step back1479 app.config["SERVER_NAME"] = "dev.local:5000"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1480why, one step back1480 rv = client.get("/")Merge branch '1.0.x'David Lordbefore adoption29111a3
line 1481why, one step back1481 assert rv.data == b"default"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1482why, one step back1482Merge branch '1.0.x'David Lordbefore adoption29111a3
lines 1483–1484why, one step back1483 rv = client.get("/", "http://dev.local:5000")1484 assert rv.data == b"default"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1485why, one step back1485Merge branch '1.0.x'David Lordbefore adoption29111a3
lines 1486–1487why, one step back1486 rv = client.get("/", "https://dev.local:5000")1487 assert rv.data == b"default"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1488why, one step back1488Merge branch '1.0.x'David Lordbefore adoption29111a3
lines 1489–1490why, one step back1489 app.config["SERVER_NAME"] = "dev.local:443"1490 rv = client.get("/", "https://dev.local")Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1491why, one step back1491Merge branch '1.0.x'David Lordbefore adoption29111a3
lines 1492–1494why, one step back1492 # Werkzeug 1.0 fixes matching https scheme with 443 port1493 if rv.status_code != 404:1494 assert rv.data == b"default"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1495why, one step back1495Merge branch '1.0.x'David Lordbefore adoption29111a3
lines 1496–1501why, one step back1496 app.config["SERVER_NAME"] = "dev.local"1497 rv = client.get("/", "https://dev.local")1498 assert rv.data == b"default"14991500 # suppress Werkzeug 1.0 warning about name mismatch1501 with pytest.warns(None):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1502–1504why, one step back1502 rv = client.get("/", "http://foo.localhost")1503 assert rv.status_code == 4041504Merge branch '1.0.x'David Lordbefore adoption29111a3
lines 1505–1506why, one step back1505 rv = client.get("/", "http://foo.dev.local")1506 assert rv.data == b"subdomain"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1507–1508why, one step back15071508Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1509–1510why, one step back1509def test_exception_propagation(app, client):1510 def apprunner(config_key):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1511–1514why, one step back1511 @app.route("/")1512 def index():1513 1 // 01514Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1515–1517why, one step back1515 if config_key is not None:1516 app.config[config_key] = True1517 with pytest.raises(Exception):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1518–1521why, one step back1518 client.get("/")1519 else:1520 assert client.get("/").status_code == 5001521Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1522–1525why, one step back1522 # we have to run this test in an isolated thread because if the1523 # debug flag is set to true and an exception happens the context is1524 # not torn down. This causes other tests that run after this fail1525 # when they expect no exception on the stack.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1526why, one step back1526 for config_key in "TESTING", "PROPAGATE_EXCEPTIONS", "DEBUG", None:Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1527–1529why, one step back1527 t = Thread(target=apprunner, args=(config_key,))1528 t.start()1529 t.join()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1530–1546why, one step back153015311532@pytest.mark.parametrize("debug", [True, False])1533@pytest.mark.parametrize("use_debugger", [True, False])1534@pytest.mark.parametrize("use_reloader", [True, False])1535@pytest.mark.parametrize("propagate_exceptions", [None, True, False])1536def test_werkzeug_passthrough_errors(1537 monkeypatch, debug, use_debugger, use_reloader, propagate_exceptions, app1538):1539 rv = {}15401541 # Mocks werkzeug.serving.run_simple method1542 def run_simple_mock(*args, **kwargs):1543 rv["passthrough_errors"] = kwargs.get("passthrough_errors")15441545 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)1546 app.config["PROPAGATE_EXCEPTIONS"] = propagate_exceptionsMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1547why, one step back1547 app.run(debug=debug, use_debugger=use_debugger, use_reloader=use_reloader)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1548–1549why, one step back15481549Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1550why, one step back1550def test_max_content_length(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1551–1553why, one step back1551 app.config["MAX_CONTENT_LENGTH"] = 6415521553 @app.before_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1554why, one step back1554 def always_first():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1555why, one step back1555 flask.request.form["myfile"]Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86
line 1556why, one step back1556 AssertionError()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1557–1558why, one step back15571558 @app.route("/accept", methods=["POST"])Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1559why, one step back1559 def accept_file():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1560why, one step back1560 flask.request.form["myfile"]Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86
line 1561why, one step back1561 AssertionError()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1562why, one step back1562Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1563–1564why, one step back1563 @app.errorhandler(413)1564 def catcher(error):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1565–1570why, one step back1565 return "42"15661567 rv = client.post("/accept", data={"myfile": "foo" * 100})1568 assert rv.data == b"42"15691570Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1571–1573why, one step back1571def test_url_processors(app, client):1572 @app.url_defaults1573 def add_language_code(endpoint, values):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1574–1578why, one step back1574 if flask.g.lang_code is not None and app.url_map.is_endpoint_expecting(1575 endpoint, "lang_code"1576 ):1577 values.setdefault("lang_code", flask.g.lang_code)1578Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1579–1580why, one step back1579 @app.url_value_preprocessor1580 def pull_lang_code(endpoint, values):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1581–1587why, one step back1581 flask.g.lang_code = values.pop("lang_code", None)15821583 @app.route("/<lang_code>/")1584 def index():1585 return flask.url_for("about")15861587 @app.route("/<lang_code>/about")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1588why, one step back1588 def about():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1589–1591why, one step back1589 return flask.url_for("something_else")15901591 @app.route("/foo")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1592why, one step back1592 def something_else():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1593–1599why, one step back1593 return flask.url_for("about", lang_code="en")15941595 assert client.get("/de/").data == b"/de/about"1596 assert client.get("/de/about").data == b"/foo"1597 assert client.get("/foo").data == b"/en/about"15981599Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1600why, one step back1600def test_inject_blueprint_url_defaults(app):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1601–1602why, one step back1601 bp = flask.Blueprint("foo.bar.baz", __name__, template_folder="template")1602Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1603–1604why, one step back1603 @bp.url_defaults1604 def bp_defaults(endpoint, values):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1605–1607why, one step back1605 values["page"] = "login"16061607 @bp.route("/<page>")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1608why, one step back1608 def view(page):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1609–1610why, one step back1609 pass1610Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1611why, one step back1611 app.register_blueprint(bp)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1612why, one step back1612Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1613why, one step back1613 values = dict()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1614–1615why, one step back1614 app.inject_url_defaults("foo.bar.baz.view", values)1615 expected = dict(page="login")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1616why, one step back1616 assert values == expectedMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1617–1620why, one step back16171618 with app.test_request_context("/somepage"):1619 url = flask.url_for("foo.bar.baz.view")1620 expected = "/login"Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1621why, one step back1621 assert url == expectedMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1622–1623why, one step back16221623Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1624why, one step back1624def test_nonascii_pathinfo(app, client):Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 1625why, one step back1625 @app.route("/киртест")Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1626–1628why, one step back1626 def index():1627 return "Hello World!"1628Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 1629why, one step back1629 rv = client.get("/киртест")Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1630–1632why, one step back1630 assert rv.data == b"Hello World!"16311632Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1633why, one step back1633def test_debug_mode_complains_after_first_request(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1634–1639why, one step back1634 app.debug = True16351636 @app.route("/")1637 def index():1638 return "Awesome"1639Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1640why, one step back1640 assert not app.got_first_requestMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1641why, one step back1641 assert client.get("/").data == b"Awesome"Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1642why, one step back1642 with pytest.raises(AssertionError) as e:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1643–1644why, one step back16431644 @app.route("/foo")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1645why, one step back1645 def broken():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1646–1647why, one step back1646 return "Meh"1647Merge branch '1.0.x'David Lordbefore adoptionb05a685
line 1648why, one step back1648 assert "A setup function was called" in str(e.value)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1649–1652why, one step back16491650 app.debug = False16511652 @app.route("/foo")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1653why, one step back1653 def working():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1654–1659why, one step back1654 return "Meh"16551656 assert client.get("/foo").data == b"Meh"1657 assert app.got_first_request16581659Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1660why, one step back1660def test_before_first_request_functions(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1661–1673why, one step back1661 got = []16621663 @app.before_first_request1664 def foo():1665 got.append(42)16661667 client.get("/")1668 assert got == [42]1669 client.get("/")1670 assert got == [42]1671 assert app.got_first_request16721673Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1674why, one step back1674def test_before_first_request_functions_concurrent(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1675–1678why, one step back1675 got = []16761677 @app.before_first_request1678 def foo():Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1679why, one step back1679 time.sleep(0.2)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1680–1681why, one step back1680 got.append(42)1681Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1682why, one step back1682 def get_and_assert():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1683why, one step back1683 client.get("/")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1684why, one step back1684 assert got == [42]Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1685why, one step back1685Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1686–1689why, one step back1686 t = Thread(target=get_and_assert)1687 t.start()1688 get_and_assert()1689 t.join()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1690–1692why, one step back1690 assert app.got_first_request16911692Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1693why, one step back1693def test_routing_redirect_debugging(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1694–1700why, one step back1694 app.debug = True16951696 @app.route("/foo/", methods=["GET", "POST"])1697 def foo():1698 return "success"16991700 with client:Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1701why, one step back1701 with pytest.raises(AssertionError) as e:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1702why, one step back1702 client.post("/foo", data={})Merge branch '1.0.x'David Lordbefore adoptionb05a685
line 1703why, one step back1703 assert "http://localhost/foo/" in str(e.value)Merge pull request #3453 from noviluni/remove_redundant_parenthesesDavid Lordbefore adoption986871b
line 1704why, one step back1704 assert "Make sure to directly send your POST-request to this URL" in str(Merge branch '1.0.x'David Lordbefore adoptionb05a685
lines 1705–1706why, one step back1705 e.value1706 )Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1707–1716why, one step back17071708 rv = client.get("/foo", data={}, follow_redirects=True)1709 assert rv.data == b"success"17101711 app.debug = False1712 with client:1713 rv = client.post("/foo", data={}, follow_redirects=True)1714 assert rv.data == b"success"17151716Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1717why, one step back1717def test_route_decorator_custom_endpoint(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1718–1724why, one step back1718 app.debug = True17191720 @app.route("/foo/")1721 def foo():1722 return flask.request.endpoint17231724 @app.route("/bar/", endpoint="bar")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1725why, one step back1725 def for_bar():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1726–1728why, one step back1726 return flask.request.endpoint17271728 @app.route("/bar/123", endpoint="123")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1729why, one step back1729 def for_bar_foo():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1730–1741why, one step back1730 return flask.request.endpoint17311732 with app.test_request_context():1733 assert flask.url_for("foo") == "/foo/"1734 assert flask.url_for("bar") == "/bar/"1735 assert flask.url_for("123") == "/bar/123"17361737 assert client.get("/foo/").data == b"foo"1738 assert client.get("/bar/").data == b"bar"1739 assert client.get("/bar/123").data == b"123"17401741Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1742why, one step back1742def test_preserve_only_once(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1743–1748why, one step back1743 app.debug = True17441745 @app.route("/fail")1746 def fail_func():1747 1 // 01748Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86
line 1749why, one step back1749 for _x in range(3):Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1750why, one step back1750 with pytest.raises(ZeroDivisionError):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1751–1752why, one step back1751 client.get("/fail")1752Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1753–1758why, one step back1753 assert flask._request_ctx_stack.top is not None1754 assert flask._app_ctx_stack.top is not None1755 # implicit appctx disappears too1756 flask._request_ctx_stack.top.pop()1757 assert flask._request_ctx_stack.top is None1758 assert flask._app_ctx_stack.top is NoneMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1759–1760why, one step back17591760Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1761why, one step back1761def test_preserve_remembers_exception(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1762why, one step back1762 app.debug = TrueMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1763why, one step back1763 errors = []Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1764–1769why, one step back17641765 @app.route("/fail")1766 def fail_func():1767 1 // 017681769 @app.route("/success")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1770why, one step back1770 def success_func():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1771–1773why, one step back1771 return "Okay"17721773 @app.teardown_requestMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1774–1775why, one step back1774 def teardown_handler(exc):1775 errors.append(exc)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1776why, one step back1776Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1777–1778why, one step back1777 # After this failure we did not yet call the teardown handler1778 with pytest.raises(ZeroDivisionError):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1779why, one step back1779 client.get("/fail")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1780why, one step back1780 assert errors == []Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1781why, one step back1781Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1782why, one step back1782 # But this request triggers it, and it's an errorMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1783why, one step back1783 client.get("/success")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1784–1785why, one step back1784 assert len(errors) == 21785 assert isinstance(errors[0], ZeroDivisionError)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1786why, one step back1786Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1787why, one step back1787 # At this point another request does nothing.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1788why, one step back1788 client.get("/success")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1789–1790why, one step back1789 assert len(errors) == 31790 assert errors[1] is NoneMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1791–1792why, one step back17911792Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1793why, one step back1793def test_get_method_on_g(app_ctx):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1794–1795why, one step back1794 assert flask.g.get("x") is None1795 assert flask.g.get("x", 11) == 11Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1796why, one step back1796 flask.g.x = 42Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1797why, one step back1797 assert flask.g.get("x") == 42Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1798why, one step back1798 assert flask.g.x == 42Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1799–1800why, one step back17991800Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1801–1803why, one step back1801def test_g_iteration_protocol(app_ctx):1802 flask.g.foo = 231803 flask.g.bar = 42Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1804–1808why, one step back1804 assert "foo" in flask.g1805 assert "foos" not in flask.g1806 assert sorted(flask.g) == ["bar", "foo"]18071808Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1809why, one step back1809def test_subdomain_basic_support():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1810–1814why, one step back1810 app = flask.Flask(__name__, subdomain_matching=True)1811 app.config["SERVER_NAME"] = "localhost.localdomain"1812 client = app.test_client()18131814 @app.route("/")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1815why, one step back1815 def normal_index():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1816–1818why, one step back1816 return "normal index"18171818 @app.route("/", subdomain="test")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1819why, one step back1819 def test_index():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1820–1828why, one step back1820 return "test index"18211822 rv = client.get("/", "http://localhost.localdomain/")1823 assert rv.data == b"normal index"18241825 rv = client.get("/", "http://test.localhost.localdomain/")1826 assert rv.data == b"test index"18271828Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1829why, one step back1829def test_subdomain_matching():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1830–1835why, one step back1830 app = flask.Flask(__name__, subdomain_matching=True)1831 client = app.test_client()1832 app.config["SERVER_NAME"] = "localhost.localdomain"18331834 @app.route("/", subdomain="<user>")1835 def index(user):Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 1836why, one step back1836 return f"index for {user}"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1837–1841why, one step back18371838 rv = client.get("/", "http://mitsuhiko.localhost.localdomain/")1839 assert rv.data == b"index for mitsuhiko"18401841Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1842why, one step back1842def test_subdomain_matching_with_ports():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1843–1848why, one step back1843 app = flask.Flask(__name__, subdomain_matching=True)1844 app.config["SERVER_NAME"] = "localhost.localdomain:3000"1845 client = app.test_client()18461847 @app.route("/", subdomain="<user>")1848 def index(user):Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 1849why, one step back1849 return f"index for {user}"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1850–1855why, one step back18501851 rv = client.get("/", "http://mitsuhiko.localhost.localdomain:3000/")1852 assert rv.data == b"index for mitsuhiko"185318541855@pytest.mark.parametrize("matching", (False, True))Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1856–1857why, one step back1856def test_subdomain_matching_other_name(matching):1857 app = flask.Flask(__name__, subdomain_matching=matching)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1858–1864why, one step back1858 app.config["SERVER_NAME"] = "localhost.localdomain:3000"1859 client = app.test_client()18601861 @app.route("/")1862 def index():1863 return "", 2041864Merge branch '1.0.x'David Lordbefore adoption29111a3
lines 1865–1869why, one step back1865 # suppress Werkzeug 0.15 warning about name mismatch1866 with pytest.warns(None):1867 # ip address can't match name1868 rv = client.get("/", "http://127.0.0.1:3000/")1869 assert rv.status_code == 404 if matching else 204Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1870why, one step back1870Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1871why, one step back1871 # allow all subdomains if matching is disabledMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1872–1875why, one step back1872 rv = client.get("/", "http://www.localhost.localdomain:3000/")1873 assert rv.status_code == 404 if matching else 20418741875Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1876why, one step back1876def test_multi_route_rules(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1877–1879why, one step back1877 @app.route("/")1878 @app.route("/<test>/")1879 def index(test="a"):Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1880why, one step back1880 return testMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1881–1887why, one step back18811882 rv = client.open("/")1883 assert rv.data == b"a"1884 rv = client.open("/b/")1885 assert rv.data == b"b"18861887Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1888why, one step back1888def test_multi_route_class_views(app, client):Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 1889why, one step back1889 class View:Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1890why, one step back1890 def __init__(self, app):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1891–1894why, one step back1891 app.add_url_rule("/", "index", self.index)1892 app.add_url_rule("/<test>/", "index", self.index)18931894 def index(self, test="a"):Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1895why, one step back1895 return testMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1896why, one step back1896Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1897why, one step back1897 _ = View(app)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1898–1903why, one step back1898 rv = client.open("/")1899 assert rv.data == b"a"1900 rv = client.open("/b/")1901 assert rv.data == b"b"19021903Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1904why, one step back1904def test_run_defaults(monkeypatch, app):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1905–1911why, one step back1905 rv = {}19061907 # Mocks werkzeug.serving.run_simple method1908 def run_simple_mock(*args, **kwargs):1909 rv["result"] = "running..."19101911 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1912why, one step back1912 app.run()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1913–1915why, one step back1913 assert rv["result"] == "running..."19141915Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1916why, one step back1916def test_run_server_port(monkeypatch, app):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1917–1919why, one step back1917 rv = {}19181919 # Mocks werkzeug.serving.run_simple methodMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1920why, one step back1920 def run_simple_mock(hostname, port, application, *args, **kwargs):Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 1921why, one step back1921 rv["result"] = f"running on {hostname}:{port} ..."Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1922–1924why, one step back19221923 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)1924 hostname, port = "localhost", 8000Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1925why, one step back1925 app.run(hostname, port, debug=True)Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374
line 1926why, one step back1926 assert rv["result"] == f"running on {hostname}:{port} ..."Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1927–1929why, one step back192719281929@pytest.mark.parametrize(Merge pull request #2928 from vorelq/2926-default-port-overrides-zeroDavid Lordbefore adoptiond9fa28b
line 1930why, one step back1930 "host,port,server_name,expect_host,expect_port",Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1931why, one step back1931 (Merge pull request #2928 from vorelq/2926-default-port-overrides-zeroDavid Lordbefore adoptiond9fa28b
lines 1932–1938why, one step back1932 (None, None, "pocoo.org:8080", "pocoo.org", 8080),1933 ("localhost", None, "pocoo.org:8080", "localhost", 8080),1934 (None, 80, "pocoo.org:8080", "pocoo.org", 80),1935 ("localhost", 80, "pocoo.org:8080", "localhost", 80),1936 ("localhost", 0, "localhost:8080", "localhost", 0),1937 (None, None, "localhost:8080", "localhost", 8080),1938 (None, None, "localhost:0", "localhost", 0),Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1939–1940why, one step back1939 ),1940)Merge pull request #3229 from lordmauve/style-fixDavid Lordbefore adoption240e398
lines 1941–1943why, one step back1941def test_run_from_config(1942 monkeypatch, host, port, server_name, expect_host, expect_port, app1943):Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1944–1946why, one step back1944 def run_simple_mock(hostname, port, *args, **kwargs):1945 assert hostname == expect_host1946 assert port == expect_portMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1947–1948why, one step back19471948 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)Merge pull request #2928 from vorelq/2926-default-port-overrides-zeroDavid Lordbefore adoptiond9fa28b
line 1949why, one step back1949 app.config["SERVER_NAME"] = server_nameMerge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1950why, one step back1950 app.run(host, port)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1951–1952why, one step back19511952Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1953why, one step back1953def test_max_cookie_size(app, client, recwarn):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1954–1955why, one step back1954 app.config["MAX_COOKIE_SIZE"] = 1001955Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1956–1958why, one step back1956 # outside app context, default to Werkzeug static value,1957 # which is also the default config1958 response = flask.Response()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1959why, one step back1959 default = flask.Flask.default_config["MAX_COOKIE_SIZE"]Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1960why, one step back1960 assert response.max_cookie_size == defaultMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1961why, one step back1961Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1962–1964why, one step back1962 # inside app context, use app config1963 with app.app_context():1964 assert flask.Response().max_cookie_size == 100Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1965–1969why, one step back19651966 @app.route("/")1967 def index():1968 r = flask.Response("", status=204)1969 r.set_cookie("foo", "bar" * 100)Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1970why, one step back1970 return rMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1971–1972why, one step back19711972 client.get("/")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
lines 1973–1974why, one step back1973 assert len(recwarn) == 11974 w = recwarn.pop()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1975–1979why, one step back1975 assert "cookie is too large" in str(w.message)19761977 app.config["MAX_COOKIE_SIZE"] = 019781979 client.get("/")Merge pull request #2996 from alysivji/spa-docsDavid Lordbefore adoptionb78ebac
line 1980why, one step back1980 assert len(recwarn) == 0Break reference cycle created by default in Flask instances.Bogdan Opanchukbefore adoption8efea0c
lines 1981–1996why, one step back198119821983@require_cpython_gc1984def test_app_freed_on_zero_refcount():1985 # A Flask instance should not create a reference cycle that prevents CPython1986 # from freeing it when all external references to it are released (see #3761).1987 gc.disable()1988 try:1989 app = flask.Flask(__name__)1990 assert app.view_functions["static"]1991 weak = weakref.ref(app)1992 assert weak() is not None1993 del app1994 assert weak() is None1995 finally:1996 gc.enable()