Skip to content
Myr

test_basic.py

This file

Path

tests/test_basic.py

1,955 lines · 52.4 KiB · Python

Last changed by

Merge pull request #3182 from qil026/issue-3134-url-joinDavid Lordbefore adoptiondbd3840

History of this file

Take it

The walk stopped after 200 commits: lines older than 6162ece point at it.

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1–7why, one step back
1# -*- coding: utf-8 -*-
2"""3 tests.basic4 ~~~~~~~~~~~~~~~~~~~~~56 The basic functionality.7

Merge pull request #2624 from pallets/metadataDavid Lordbefore adoption4309c7c

line 8why, one step back
8 :copyright: © 2010 by the Pallets team.

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 9–28why, one step back
9 :license: BSD, see LICENSE for more details.
10"""1112import re13import time14import uuid15from datetime import datetime16from threading import Thread1718import pytest19import werkzeug.serving20from werkzeug.exceptions import BadRequest, Forbidden, NotFound21from werkzeug.http import parse_date22from werkzeug.routing import BuildError2324import flask25from flask._compat import text_type262728def test_options_work(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 29–37why, one step back
29 @app.route("/", methods=["GET", "POST"])
30 def index():31 return "Hello World"3233 rv = client.open("/", method="OPTIONS")34 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS", "POST"]35 assert rv.data == b""3637

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 38why, one step back
38def test_options_on_multiple_rules(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 39–43why, one step back
39 @app.route("/", methods=["GET", "POST"])
40 def index():41 return "Hello World"4243 @app.route("/", methods=["PUT"])

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 44why, one step back
44 def index_put():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 45–50why, one step back
45 return "Aha!"
4647 rv = client.open("/", method="OPTIONS")48 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS", "POST", "PUT"]4950

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 51why, one step back
51def test_provide_automatic_options_attr():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 52–56why, one step back
52 app = flask.Flask(__name__)
5354 def index():55 return "Hello World!"56

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 57why, one step back
57 index.provide_automatic_options = False

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 58–66why, one step back
58 app.route("/")(index)
59 rv = app.test_client().open("/", method="OPTIONS")60 assert rv.status_code == 4056162 app = flask.Flask(__name__)6364 def index2():65 return "Hello World!"66

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 67why, one step back
67 index2.provide_automatic_options = True

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 68–72why, one step back
68 app.route("/", methods=["OPTIONS"])(index2)
69 rv = app.test_client().open("/", method="OPTIONS")70 assert sorted(rv.allow) == ["OPTIONS"]7172

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 73why, one step back
73def test_provide_automatic_options_kwarg(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 74–80why, one step back
74 def index():
75 return flask.request.method7677 def more():78 return flask.request.method7980 app.add_url_rule("/", view_func=index, provide_automatic_options=False)

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 81why, one step back
81 app.add_url_rule(

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 82–92why, one step back
82 "/more",
83 view_func=more,84 methods=["GET", "POST"],85 provide_automatic_options=False,86 )87 assert client.get("/").data == b"GET"8889 rv = client.post("/")90 assert rv.status_code == 40591 assert sorted(rv.allow) == ["GET", "HEAD"]92

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 93why, one step back
93 # Older versions of Werkzeug.test.Client don't have an options method

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 94–118why, one step back
94 if hasattr(client, "options"):
95 rv = client.options("/")96 else:97 rv = client.open("/", method="OPTIONS")9899 assert rv.status_code == 405100101 rv = client.head("/")102 assert rv.status_code == 200103 assert not rv.data # head truncates104 assert client.post("/more").data == b"POST"105 assert client.get("/more").data == b"GET"106107 rv = client.delete("/more")108 assert rv.status_code == 405109 assert sorted(rv.allow) == ["GET", "HEAD", "POST"]110111 if hasattr(client, "options"):112 rv = client.options("/more")113 else:114 rv = client.open("/more", method="OPTIONS")115116 assert rv.status_code == 405117118

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 119why, one step back
119def test_request_dispatching(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 120–141why, one step back
120 @app.route("/")
121 def index():122 return flask.request.method123124 @app.route("/more", methods=["GET", "POST"])125 def more():126 return flask.request.method127128 assert client.get("/").data == b"GET"129 rv = client.post("/")130 assert rv.status_code == 405131 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS"]132 rv = client.head("/")133 assert rv.status_code == 200134 assert not rv.data # head truncates135 assert client.post("/more").data == b"POST"136 assert client.get("/more").data == b"GET"137 rv = client.delete("/more")138 assert rv.status_code == 405139 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS", "POST"]140141

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 142–143why, one step back
142def test_disallow_string_for_allowed_methods(app):
143 with pytest.raises(TypeError):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 144–146why, one step back
144
145 @app.route("/", methods="GET POST")146 def index():

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 147why, one step back
147 return "Hey"

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 148–149why, one step back
148
149

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 150–151why, one step back
150def test_url_mapping(app, client):
151 random_uuid4 = "7eb41166-9ebf-4d26-b771-ea3f54f8b383"

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 152–158why, one step back
152
153 def index():154 return flask.request.method155156 def more():157 return flask.request.method158

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 159–160why, one step back
159 def options():
160 return random_uuid4

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 161–164why, one step back
161
162 app.add_url_rule("/", "index", index)163 app.add_url_rule("/more", "more", more, methods=["GET", "POST"])164

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 165why, one step back
165 # Issue 1288: Test that automatic options are not added when non-uppercase 'options' in methods

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 166–181why, one step back
166 app.add_url_rule("/options", "options", options, methods=["options"])
167168 assert client.get("/").data == b"GET"169 rv = client.post("/")170 assert rv.status_code == 405171 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS"]172 rv = client.head("/")173 assert rv.status_code == 200174 assert not rv.data # head truncates175 assert client.post("/more").data == b"POST"176 assert client.get("/more").data == b"GET"177 rv = client.delete("/more")178 assert rv.status_code == 405179 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS", "POST"]180 rv = client.open("/options", method="OPTIONS")181 assert rv.status_code == 200

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 182why, one step back
182 assert random_uuid4 in rv.data.decode("utf-8")

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 183–184why, one step back
183
184

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 185why, one step back
185def test_werkzeug_routing(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 186–204why, one step back
186 from werkzeug.routing import Submount, Rule
187188 app.url_map.add(189 Submount("/foo", [Rule("/bar", endpoint="bar"), Rule("/", endpoint="index")])190 )191192 def bar():193 return "bar"194195 def index():196 return "index"197198 app.view_functions["bar"] = bar199 app.view_functions["index"] = index200201 assert client.get("/foo/").data == b"index"202 assert client.get("/foo/bar").data == b"bar"203204

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 205why, one step back
205def test_endpoint_decorator(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 206–223why, one step back
206 from werkzeug.routing import Submount, Rule
207208 app.url_map.add(209 Submount("/foo", [Rule("/bar", endpoint="bar"), Rule("/", endpoint="index")])210 )211212 @app.endpoint("bar")213 def bar():214 return "bar"215216 @app.endpoint("index")217 def index():218 return "index"219220 assert client.get("/foo/").data == b"index"221 assert client.get("/foo/bar").data == b"bar"222223

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 224why, one step back
224def test_session(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 225why, one step back
225 @app.route("/set", methods=["POST"])

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 226why, one step back
226 def set():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 227–230why, one step back
227 assert not flask.session.accessed
228 assert not flask.session.modified229 flask.session["value"] = flask.request.form["value"]230 assert flask.session.accessed

Merge pull request #2580 from pallets/session-attrsDavid Lordbefore adoption26f413e

line 231why, one step back
231 assert flask.session.modified

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 232–240why, one step back
232 return "value set"
233234 @app.route("/get")235 def get():236 assert not flask.session.accessed237 assert not flask.session.modified238 v = flask.session.get("value", "None")239 assert flask.session.accessed240 assert not flask.session.modified

Merge pull request #2580 from pallets/session-attrsDavid Lordbefore adoption26f413e

line 241why, one step back
241 return v

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 242–246why, one step back
242
243 assert client.post("/set", data={"value": "42"}).data == b"value set"244 assert client.get("/get").data == b"42"245246

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 247why, one step back
247def test_session_using_server_name(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 248–259why, one step back
248 app.config.update(SERVER_NAME="example.com")
249250 @app.route("/")251 def index():252 flask.session["testing"] = 42253 return "Hello World"254255 rv = client.get("/", "http://example.com/")256 assert "domain=.example.com" in rv.headers["set-cookie"].lower()257 assert "httponly" in rv.headers["set-cookie"].lower()258259

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 260why, one step back
260def test_session_using_server_name_and_port(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 261–272why, one step back
261 app.config.update(SERVER_NAME="example.com:8080")
262263 @app.route("/")264 def index():265 flask.session["testing"] = 42266 return "Hello World"267268 rv = client.get("/", "http://example.com:8080/")269 assert "domain=.example.com" in rv.headers["set-cookie"].lower()270 assert "httponly" in rv.headers["set-cookie"].lower()271272

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 273why, one step back
273def test_session_using_server_name_port_and_path(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 274–286why, one step back
274 app.config.update(SERVER_NAME="example.com:8080", APPLICATION_ROOT="/foo")
275276 @app.route("/")277 def index():278 flask.session["testing"] = 42279 return "Hello World"280281 rv = client.get("/", "http://example.com:8080/foo")282 assert "domain=example.com" in rv.headers["set-cookie"].lower()283 assert "path=/foo" in rv.headers["set-cookie"].lower()284 assert "httponly" in rv.headers["set-cookie"].lower()285286

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 287–291why, one step back
287def test_session_using_application_root(app, client):
288 class PrefixPathMiddleware(object):289 def __init__(self, app, prefix):290 self.app = app291 self.prefix = prefix

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 292why, one step back
292

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 293why, one step back
293 def __call__(self, environ, start_response):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 294why, one step back
294 environ["SCRIPT_NAME"] = self.prefix

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 295why, one step back
295 return self.app(environ, start_response)

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 296–308why, one step back
296
297 app.wsgi_app = PrefixPathMiddleware(app.wsgi_app, "/bar")298 app.config.update(APPLICATION_ROOT="/bar")299300 @app.route("/")301 def index():302 flask.session["testing"] = 42303 return "Hello World"304305 rv = client.get("/", "http://example.com:8080/")306 assert "path=/bar" in rv.headers["set-cookie"].lower()307308

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 309why, one step back
309def test_session_using_session_settings(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 310–313why, one step back
310 app.config.update(
311 SERVER_NAME="www.example.com:8080",312 APPLICATION_ROOT="/test",313 SESSION_COOKIE_DOMAIN=".example.com",

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 314–315why, one step back
314 SESSION_COOKIE_HTTPONLY=False,
315 SESSION_COOKIE_SECURE=True,

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 316–333why, one step back
316 SESSION_COOKIE_SAMESITE="Lax",
317 SESSION_COOKIE_PATH="/",318 )319320 @app.route("/")321 def index():322 flask.session["testing"] = 42323 return "Hello World"324325 rv = client.get("/", "http://www.example.com:8080/test/")326 cookie = rv.headers["set-cookie"].lower()327 assert "domain=.example.com" in cookie328 assert "path=/" in cookie329 assert "secure" in cookie330 assert "httponly" not in cookie331 assert "samesite" in cookie332333

Merge pull request #2607 from FadhelC/SameSite-cookie-featureDavid Lordbefore adoptione21abd9

line 334why, one step back
334def test_session_using_samesite_attribute(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 335–341why, one step back
335 @app.route("/")
336 def index():337 flask.session["testing"] = 42338 return "Hello World"339340 app.config.update(SESSION_COOKIE_SAMESITE="invalid")341

Merge pull request #2607 from FadhelC/SameSite-cookie-featureDavid Lordbefore adoptione21abd9

line 342why, one step back
342 with pytest.raises(ValueError):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 343–344why, one step back
343 client.get("/")
344

Merge pull request #2607 from FadhelC/SameSite-cookie-featureDavid Lordbefore adoptione21abd9

line 345why, one step back
345 app.config.update(SESSION_COOKIE_SAMESITE=None)

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 346–360why, one step back
346 rv = client.get("/")
347 cookie = rv.headers["set-cookie"].lower()348 assert "samesite" not in cookie349350 app.config.update(SESSION_COOKIE_SAMESITE="Strict")351 rv = client.get("/")352 cookie = rv.headers["set-cookie"].lower()353 assert "samesite=strict" in cookie354355 app.config.update(SESSION_COOKIE_SAMESITE="Lax")356 rv = client.get("/")357 cookie = rv.headers["set-cookie"].lower()358 assert "samesite=lax" in cookie359360

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 361why, one step back
361def test_session_localhost_warning(recwarn, app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 362–371why, one step back
362 app.config.update(SERVER_NAME="localhost:5000")
363364 @app.route("/")365 def index():366 flask.session["testing"] = 42367 return "testing"368369 rv = client.get("/", "http://localhost:5000/")370 assert "domain" not in rv.headers["set-cookie"].lower()371 w = recwarn.pop(UserWarning)

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 372why, one step back
372 assert '"localhost" is not a valid cookie domain' in str(w.message)

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 373–374why, one step back
373
374

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 375why, one step back
375def test_session_ip_warning(recwarn, app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 376–388why, one step back
376 app.config.update(SERVER_NAME="127.0.0.1:5000")
377378 @app.route("/")379 def index():380 flask.session["testing"] = 42381 return "testing"382383 rv = client.get("/", "http://127.0.0.1:5000/")384 assert "domain=127.0.0.1" in rv.headers["set-cookie"].lower()385 w = recwarn.pop(UserWarning)386 assert "cookie domain is an IP" in str(w.message)387388

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 389–390why, one step back
389def test_missing_session(app):
390 app.secret_key = None

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 391why, one step back
391

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 392–393why, one step back
392 def expect_exception(f, *args, **kwargs):
393 e = pytest.raises(RuntimeError, f, *args, **kwargs)

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 394–401why, one step back
394 assert e.value.args and "session is unavailable" in e.value.args[0]
395396 with app.test_request_context():397 assert flask.session.get("missing_key") is None398 expect_exception(flask.session.__setitem__, "foo", 42)399 expect_exception(flask.session.pop, "foo")400401

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 402–403why, one step back
402def test_session_expiration(app, client):
403 permanent = True

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 404–407why, one step back
404
405 @app.route("/")406 def index():407 flask.session["test"] = 42

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 408why, one step back
408 flask.session.permanent = permanent

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 409–412why, one step back
409 return ""
410411 @app.route("/test")412 def test():

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 413why, one step back
413 return text_type(flask.session.permanent)

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 414–417why, one step back
414
415 rv = client.get("/")416 assert "set-cookie" in rv.headers417 match = re.search(r"(?i)\bexpires=([^;]+)", rv.headers["set-cookie"])

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 418–422why, one step back
418 expires = parse_date(match.group())
419 expected = datetime.utcnow() + app.permanent_session_lifetime420 assert expires.year == expected.year421 assert expires.month == expected.month422 assert expires.day == expected.day

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 423–426why, one step back
423
424 rv = client.get("/test")425 assert rv.data == b"True"426

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 427why, one step back
427 permanent = False

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 428–430why, one step back
428 rv = client.get("/")
429 assert "set-cookie" in rv.headers430 match = re.search(r"\bexpires=([^;]+)", rv.headers["set-cookie"])

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 431why, one step back
431 assert match is None

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 432–433why, one step back
432
433

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 434why, one step back
434def test_session_stored_last(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 435why, one step back
435 @app.after_request

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 436why, one step back
436 def modify_session(response):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 437–447why, one step back
437 flask.session["foo"] = 42
438 return response439440 @app.route("/")441 def dump_session_contents():442 return repr(flask.session.get("foo"))443444 assert client.get("/").data == b"None"445 assert client.get("/").data == b"42"446447

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 448–450why, one step back
448def test_session_special_types(app, client):
449 now = datetime.utcnow().replace(microsecond=0)450 the_uuid = uuid.uuid4()

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 451–465why, one step back
451
452 @app.route("/")453 def dump_session_contents():454 flask.session["t"] = (1, 2, 3)455 flask.session["b"] = b"\xff"456 flask.session["m"] = flask.Markup("<html>")457 flask.session["u"] = the_uuid458 flask.session["d"] = now459 flask.session["t_tag"] = {" t": "not-a-tuple"}460 flask.session["di_t_tag"] = {" t__": "not-a-tuple"}461 flask.session["di_tag"] = {" di": "not-a-dict"}462 return "", 204463464 with client:465 client.get("/")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 466why, one step back
466 s = flask.session

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 467–478why, one step back
467 assert s["t"] == (1, 2, 3)
468 assert type(s["b"]) == bytes469 assert s["b"] == b"\xff"470 assert type(s["m"]) == flask.Markup471 assert s["m"] == flask.Markup("<html>")472 assert s["u"] == the_uuid473 assert s["d"] == now474 assert s["t_tag"] == {" t": "not-a-tuple"}475 assert s["di_t_tag"] == {" t__": "not-a-tuple"}476 assert s["di_tag"] == {" di": "not-a-dict"}477478

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 479why, one step back
479def test_session_cookie_setting(app):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 480–482why, one step back
480 is_permanent = True
481482 @app.route("/bump")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 483why, one step back
483 def bump():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 484why, one step back
484 rv = flask.session["foo"] = flask.session.get("foo", 0) + 1

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 485–486why, one step back
485 flask.session.permanent = is_permanent
486 return str(rv)

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 487–488why, one step back
487
488 @app.route("/read")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 489why, one step back
489 def read():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 490–491why, one step back
490 return str(flask.session.get("foo", 0))
491

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 492–493why, one step back
492 def run_test(expect_header):
493 with app.test_client() as c:

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 494–499why, one step back
494 assert c.get("/bump").data == b"1"
495 assert c.get("/bump").data == b"2"496 assert c.get("/bump").data == b"3"497498 rv = c.get("/read")499 set_cookie = rv.headers.get("set-cookie")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 500why, one step back
500 assert (set_cookie is not None) == expect_header

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 501–504why, one step back
501 assert rv.data == b"3"
502503 is_permanent = True504 app.config["SESSION_REFRESH_EACH_REQUEST"] = True

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 505why, one step back
505 run_test(expect_header=True)

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 506–519why, one step back
506
507 is_permanent = True508 app.config["SESSION_REFRESH_EACH_REQUEST"] = False509 run_test(expect_header=False)510511 is_permanent = False512 app.config["SESSION_REFRESH_EACH_REQUEST"] = True513 run_test(expect_header=False)514515 is_permanent = False516 app.config["SESSION_REFRESH_EACH_REQUEST"] = False517 run_test(expect_header=False)518519

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 520why, one step back
520def test_session_vary_cookie(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 521why, one step back
521 @app.route("/set")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 522why, one step back
522 def set_session():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 523–530why, one step back
523 flask.session["test"] = "test"
524 return ""525526 @app.route("/get")527 def get():528 return flask.session.get("test")529530 @app.route("/getitem")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 531why, one step back
531 def getitem():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 532–534why, one step back
532 return flask.session["test"]
533534 @app.route("/setdefault")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 535why, one step back
535 def setdefault():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 536–538why, one step back
536 return flask.session.setdefault("test", "default")
537538 @app.route("/vary-cookie-header-set")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 539why, one step back
539 def vary_cookie_header_set():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 540–545why, one step back
540 response = flask.Response()
541 response.vary.add("Cookie")542 flask.session["test"] = "test"543 return response544545 @app.route("/vary-header-set")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 546why, one step back
546 def vary_header_set():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 547–552why, one step back
547 response = flask.Response()
548 response.vary.update(("Accept-Encoding", "Accept-Language"))549 flask.session["test"] = "test"550 return response551552 @app.route("/no-vary-header")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 553why, one step back
553 def no_vary_header():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 554–556why, one step back
554 return ""
555556 def expect(path, header_value="Cookie"):

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 557why, one step back
557 rv = client.get(path)

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 558why, one step back
558

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 559–560why, one step back
559 if header_value:
560 # The 'Vary' key should exist in the headers only once.

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 561–574why, one step back
561 assert len(rv.headers.get_all("Vary")) == 1
562 assert rv.headers["Vary"] == header_value563 else:564 assert "Vary" not in rv.headers565566 expect("/set")567 expect("/get")568 expect("/getitem")569 expect("/setdefault")570 expect("/vary-cookie-header-set")571 expect("/vary-header-set", "Accept-Encoding, Accept-Language, Cookie")572 expect("/no-vary-header", None)573574

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 575–576why, one step back
575def test_flashes(app, req_ctx):
576 assert not flask.session.modified

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 577why, one step back
577 flask.flash("Zap")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 578why, one step back
578 flask.session.modified = False

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 579why, one step back
579 flask.flash("Zip")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 580why, one step back
580 assert flask.session.modified

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 581–583why, one step back
581 assert list(flask.get_flashed_messages()) == ["Zap", "Zip"]
582583

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 584–589why, one step back
584def test_extended_flashing(app):
585 # Be sure app.testing=True below, else tests can fail silently.586 #587 # Specifically, if app.testing is not set to True, the AssertionErrors588 # in the view functions will cause a 500 response to the test client589 # instead of propagating exceptions.

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 590–599why, one step back
590
591 @app.route("/")592 def index():593 flask.flash(u"Hello World")594 flask.flash(u"Hello World", "error")595 flask.flash(flask.Markup(u"<em>Testing</em>"), "warning")596 return ""597598 @app.route("/test/")599 def test():

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 600why, one step back
600 messages = flask.get_flashed_messages()

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 601–608why, one step back
601 assert list(messages) == [
602 u"Hello World",603 u"Hello World",604 flask.Markup(u"<em>Testing</em>"),605 ]606 return ""607608 @app.route("/test_with_categories/")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 609–611why, one step back
609 def test_with_categories():
610 messages = flask.get_flashed_messages(with_categories=True)611 assert len(messages) == 3

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 612–619why, one step back
612 assert list(messages) == [
613 ("message", u"Hello World"),614 ("error", u"Hello World"),615 ("warning", flask.Markup(u"<em>Testing</em>")),616 ]617 return ""618619 @app.route("/test_filter/")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 620why, one step back
620 def test_filter():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 621–627why, one step back
621 messages = flask.get_flashed_messages(
622 category_filter=["message"], with_categories=True623 )624 assert list(messages) == [("message", u"Hello World")]625 return ""626627 @app.route("/test_filters/")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 628why, one step back
628 def test_filters():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 629–638why, one step back
629 messages = flask.get_flashed_messages(
630 category_filter=["message", "warning"], with_categories=True631 )632 assert list(messages) == [633 ("message", u"Hello World"),634 ("warning", flask.Markup(u"<em>Testing</em>")),635 ]636 return ""637638 @app.route("/test_filters_without_returning_categories/")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 639why, one step back
639 def test_filters2():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 640why, one step back
640 messages = flask.get_flashed_messages(category_filter=["message", "warning"])

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 641why, one step back
641 assert len(messages) == 2

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 642–645why, one step back
642 assert messages[0] == u"Hello World"
643 assert messages[1] == flask.Markup(u"<em>Testing</em>")644 return ""645

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 646why, one step back
646 # Create new test client on each test to clean flashed messages.

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 647–664why, one step back
647
648 client = app.test_client()649 client.get("/")650 client.get("/test_with_categories/")651652 client = app.test_client()653 client.get("/")654 client.get("/test_filter/")655656 client = app.test_client()657 client.get("/")658 client.get("/test_filters/")659660 client = app.test_client()661 client.get("/")662 client.get("/test_filters_without_returning_categories/")663664

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 665why, one step back
665def test_request_processing(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 666–689why, one step back
666 evts = []
667668 @app.before_request669 def before_request():670 evts.append("before")671672 @app.after_request673 def after_request(response):674 response.data += b"|after"675 evts.append("after")676 return response677678 @app.route("/")679 def index():680 assert "before" in evts681 assert "after" not in evts682 return "request"683684 assert "after" not in evts685 rv = client.get("/").data686 assert "after" in evts687 assert rv == b"request|after"688689

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 690why, one step back
690def test_request_preprocessing_early_return(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 691–693why, one step back
691 evts = []
692693 @app.before_request

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 694–695why, one step back
694 def before_request1():
695 evts.append(1)

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 696–697why, one step back
696
697 @app.before_request

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 698–700why, one step back
698 def before_request2():
699 evts.append(2)700 return "hello"

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 701–702why, one step back
701
702 @app.before_request

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 703–705why, one step back
703 def before_request3():
704 evts.append(3)705 return "bye"

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 706–709why, one step back
706
707 @app.route("/")708 def index():709 evts.append("index")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 710why, one step back
710 return "damnit"

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 711–713why, one step back
711
712 rv = client.get("/").data.strip()713 assert rv == b"hello"

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 714why, one step back
714 assert evts == [1, 2]

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 715–716why, one step back
715
716

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 717why, one step back
717def test_after_request_processing(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 718–719why, one step back
718 @app.route("/")
719 def index():

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 720–721why, one step back
720 @flask.after_this_request
721 def foo(response):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 722why, one step back
722 response.headers["X-Foo"] = "a header"

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 723why, one step back
723 return response

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 724–727why, one step back
724
725 return "Test"726727 resp = client.get("/")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 728why, one step back
728 assert resp.status_code == 200

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 729–731why, one step back
729 assert resp.headers["X-Foo"] == "a header"
730731

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 732why, one step back
732def test_teardown_request_handler(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 733–749why, one step back
733 called = []
734735 @app.teardown_request736 def teardown_request(exc):737 called.append(True)738 return "Ignored"739740 @app.route("/")741 def root():742 return "Response"743744 rv = client.get("/")745 assert rv.status_code == 200746 assert b"Response" in rv.data747 assert len(called) == 1748749

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 750why, one step back
750def test_teardown_request_handler_debug_mode(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 751–767why, one step back
751 called = []
752753 @app.teardown_request754 def teardown_request(exc):755 called.append(True)756 return "Ignored"757758 @app.route("/")759 def root():760 return "Response"761762 rv = client.get("/")763 assert rv.status_code == 200764 assert b"Response" in rv.data765 assert len(called) == 1766767

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 768why, one step back
768def test_teardown_request_handler_error(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 769–772why, one step back
769 called = []
770 app.testing = False771772 @app.teardown_request

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 773why, one step back
773 def teardown_request1(exc):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 774–784why, one step back
774 assert type(exc) == ZeroDivisionError
775 called.append(True)776 # This raises a new error and blows away sys.exc_info(), so we can777 # test that all teardown_requests get passed the same original778 # exception.779 try:780 raise TypeError()781 except:782 pass783784 @app.teardown_request

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 785why, one step back
785 def teardown_request2(exc):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 786–796why, one step back
786 assert type(exc) == ZeroDivisionError
787 called.append(True)788 # This raises a new error and blows away sys.exc_info(), so we can789 # test that all teardown_requests get passed the same original790 # exception.791 try:792 raise TypeError()793 except:794 pass795796 @app.route("/")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 797why, one step back
797 def fails():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 798–802why, one step back
798 1 // 0
799800 rv = client.get("/")801 assert rv.status_code == 500802 assert b"Internal Server Error" in rv.data

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 803why, one step back
803 assert len(called) == 2

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 804–805why, one step back
804
805

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 806why, one step back
806def test_before_after_request_order(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 807–809why, one step back
807 called = []
808809 @app.before_request

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 810–811why, one step back
810 def before1():
811 called.append(1)

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 812–813why, one step back
812
813 @app.before_request

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 814–815why, one step back
814 def before2():
815 called.append(2)

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 816–817why, one step back
816
817 @app.after_request

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 818–819why, one step back
818 def after1(response):
819 called.append(4)

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 820–822why, one step back
820 return response
821822 @app.after_request

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 823–824why, one step back
823 def after2(response):
824 called.append(3)

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 825–827why, one step back
825 return response
826827 @app.teardown_request

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 828–829why, one step back
828 def finish1(exc):
829 called.append(6)

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 830–831why, one step back
830
831 @app.teardown_request

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 832–833why, one step back
832 def finish2(exc):
833 called.append(5)

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 834–840why, one step back
834
835 @app.route("/")836 def index():837 return "42"838839 rv = client.get("/")840 assert rv.data == b"42"

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 841why, one step back
841 assert called == [1, 2, 3, 4, 5, 6]

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 842–843why, one step back
842
843

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 844why, one step back
844def test_error_handling(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 845–847why, one step back
845 app.testing = False
846847 @app.errorhandler(404)

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 848why, one step back
848 def not_found(e):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 849–854why, one step back
849 return "not found", 404
850851 @app.errorhandler(500)852 def internal_server_error(e):853 return "internal server error", 500854

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 855–856why, one step back
855 @app.errorhandler(Forbidden)
856 def forbidden(e):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 857–863why, one step back
857 return "forbidden", 403
858859 @app.route("/")860 def index():861 flask.abort(404)862863 @app.route("/error")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 864why, one step back
864 def error():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 865–867why, one step back
865 1 // 0
866867 @app.route("/forbidden")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 868why, one step back
868 def error2():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 869–877why, one step back
869 flask.abort(403)
870871 rv = client.get("/")872 assert rv.status_code == 404873 assert rv.data == b"not found"874 rv = client.get("/error")875 assert rv.status_code == 500876 assert b"internal server error" == rv.data877 rv = client.get("/forbidden")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 878why, one step back
878 assert rv.status_code == 403

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 879–881why, one step back
879 assert b"forbidden" == rv.data
880881

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 882–883why, one step back
882def test_error_handler_unknown_code(app):
883 with pytest.raises(KeyError) as exc_info:

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 884–888why, one step back
884 app.register_error_handler(999, lambda e: ("999", 999))
885886 assert "Use a subclass" in exc_info.value.args[0]887888

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 889why, one step back
889def test_error_handling_processing(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 890–900why, one step back
890 app.testing = False
891892 @app.errorhandler(500)893 def internal_server_error(e):894 return "internal server error", 500895896 @app.route("/")897 def broken_func():898 1 // 0899900 @app.after_request

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 901why, one step back
901 def after_request(resp):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 902why, one step back
902 resp.mimetype = "text/x-special"

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 903why, one step back
903 return resp

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 904–909why, one step back
904
905 resp = client.get("/")906 assert resp.mimetype == "text/x-special"907 assert resp.data == b"internal server error"908909

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 910why, one step back
910def test_baseexception_error_handling(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 911–914why, one step back
911 app.testing = False
912913 @app.route("/")914 def broken_func():

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 915why, one step back
915 raise KeyboardInterrupt()

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 916why, one step back
916

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 917why, one step back
917 with pytest.raises(KeyboardInterrupt):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 918–919why, one step back
918 client.get("/")
919

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 920–922why, one step back
920 ctx = flask._request_ctx_stack.top
921 assert ctx.preserved922 assert type(ctx._preserved_exc) is KeyboardInterrupt

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 923–924why, one step back
923
924

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 925why, one step back
925def test_before_request_and_routing_errors(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 926why, one step back
926 @app.before_request

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 927why, one step back
927 def attach_something():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 928–930why, one step back
928 flask.g.something = "value"
929930 @app.errorhandler(404)

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 931–932why, one step back
931 def return_something(error):
932 return flask.g.something, 404

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 933–938why, one step back
933
934 rv = client.get("/")935 assert rv.status_code == 404936 assert rv.data == b"value"937938

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 939–940why, one step back
939def test_user_error_handling(app, client):
940 class MyException(Exception):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 941–942why, one step back
941 pass
942

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 943–945why, one step back
943 @app.errorhandler(MyException)
944 def handle_my_exception(e):945 assert isinstance(e, MyException)

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 946–949why, one step back
946 return "42"
947948 @app.route("/")949 def index():

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 950why, one step back
950 raise MyException()

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 951–954why, one step back
951
952 assert client.get("/").data == b"42"953954

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 955–956why, one step back
955def test_http_error_subclass_handling(app, client):
956 class ForbiddenSubclass(Forbidden):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 957–958why, one step back
957 pass
958

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 959why, one step back
959 @app.errorhandler(ForbiddenSubclass)

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 960why, one step back
960 def handle_forbidden_subclass(e):

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 961why, one step back
961 assert isinstance(e, ForbiddenSubclass)

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 962–963why, one step back
962 return "banana"
963

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 964why, one step back
964 @app.errorhandler(403)

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 965why, one step back
965 def handle_forbidden_subclass(e):

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 966–967why, one step back
966 assert not isinstance(e, ForbiddenSubclass)
967 assert isinstance(e, Forbidden)

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 968–970why, one step back
968 return "apple"
969970 @app.route("/1")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 971–972why, one step back
971 def index1():
972 raise ForbiddenSubclass()

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 973–978why, one step back
973
974 @app.route("/2")975 def index2():976 flask.abort(403)977978 @app.route("/3")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 979–980why, one step back
979 def index3():
980 raise Forbidden()

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 981–986why, one step back
981
982 assert client.get("/1").data == b"banana"983 assert client.get("/2").data == b"apple"984 assert client.get("/3").data == b"apple"985986

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 987–988why, one step back
987def test_errorhandler_precedence(app, client):
988 class E1(Exception):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 989–990why, one step back
989 pass
990

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 991why, one step back
991 class E2(Exception):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 992–993why, one step back
992 pass
993

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 994why, one step back
994 class E3(E1, E2):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 995–996why, one step back
995 pass
996

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 997–998why, one step back
997 @app.errorhandler(E2)
998 def handle_e2(e):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 999–1000why, one step back
999 return "E2"
1000

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1001–1002why, one step back
1001 @app.errorhandler(Exception)
1002 def handle_exception(e):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1003–1005why, one step back
1003 return "Exception"
10041005 @app.route("/E1")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1006–1007why, one step back
1006 def raise_e1():
1007 raise E1

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1008–1009why, one step back
1008
1009 @app.route("/E3")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1010–1011why, one step back
1010 def raise_e3():
1011 raise E3

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1012–1019why, one step back
1012
1013 rv = client.get("/E1")1014 assert rv.data == b"Exception"10151016 rv = client.get("/E3")1017 assert rv.data == b"E2"10181019

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1020why, one step back
1020def test_trapping_of_bad_request_key_errors(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1021–1025why, one step back
1021 @app.route("/key")
1022 def fail():1023 flask.request.form["missing_key"]10241025 @app.route("/abort")

Merge branch '1.0-maintenance'David Lordbefore adoption1fa9185

lines 1026–1027why, one step back
1026 def allow_abort():
1027 flask.abort(400)

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1028–1035why, one step back
1028
1029 rv = client.get("/key")1030 assert rv.status_code == 4001031 assert b"missing_key" not in rv.data1032 rv = client.get("/abort")1033 assert rv.status_code == 40010341035 app.debug = True

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1036why, one step back
1036 with pytest.raises(KeyError) as e:

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 1037why, one step back
1037 client.get("/key")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1038why, one step back
1038 assert e.errisinstance(BadRequest)

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1039–1044why, one step back
1039 assert "missing_key" in e.value.get_description()
1040 rv = client.get("/abort")1041 assert rv.status_code == 40010421043 app.debug = False1044 app.config["TRAP_BAD_REQUEST_ERRORS"] = True

Merge branch '1.0-maintenance'David Lordbefore adoption1fa9185

line 1045why, one step back
1045 with pytest.raises(KeyError):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 1046why, one step back
1046 client.get("/key")

Merge branch '1.0-maintenance'David Lordbefore adoption1fa9185

line 1047why, one step back
1047 with pytest.raises(BadRequest):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1048–1050why, one step back
1048 client.get("/abort")
10491050

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1051why, one step back
1051def test_trapping_of_all_http_exceptions(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1052–1057why, one step back
1052 app.config["TRAP_HTTP_EXCEPTIONS"] = True
10531054 @app.route("/fail")1055 def fail():1056 flask.abort(404)1057

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1058why, one step back
1058 with pytest.raises(NotFound):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1059–1061why, one step back
1059 client.get("/fail")
10601061

Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469

line 1062why, one step back
1062def test_error_handler_after_processor_error(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1063–1085why, one step back
1063 app.testing = False
10641065 @app.before_request1066 def before_request():1067 if trigger == "before":1068 1 // 010691070 @app.after_request1071 def after_request(response):1072 if trigger == "after":1073 1 // 01074 return response10751076 @app.route("/")1077 def index():1078 return "Foo"10791080 @app.errorhandler(500)1081 def internal_server_error(e):1082 return "Hello Server Error", 50010831084 for trigger in "before", "after":1085 rv = client.get("/")

Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469

line 1086why, one step back
1086 assert rv.status_code == 500

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1087–1089why, one step back
1087 assert rv.data == b"Hello Server Error"
10881089

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1090–1091why, one step back
1090def test_enctype_debug_helper(app, client):
1091 from flask.debughelpers import DebugFilesKeyError

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1092–1098why, one step back
1092
1093 app.debug = True10941095 @app.route("/fail", methods=["POST"])1096 def index():1097 return flask.request.files["foo"].filename1098

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1099–1101why, one step back
1099 # with statement is important because we leave an exception on the
1100 # stack otherwise and we want to ensure that this is not the case1101 # to not negatively affect other tests.

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 1102why, one step back
1102 with client:

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1103why, one step back
1103 with pytest.raises(DebugFilesKeyError) as e:

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1104–1105why, one step back
1104 client.post("/fail", data={"foo": "index.txt"})
1105 assert "no file contents were transmitted" in str(e.value)

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1106why, one step back
1106 assert 'This was submitted: "index.txt"' in str(e.value)

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1107–1108why, one step back
1107
1108

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1109why, one step back
1109def test_response_types(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 1110why, one step back
1110 @app.route("/text")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1111why, one step back
1111 def from_text():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1112–1114why, one step back
1112 return u"Hällo Wörld"
11131114 @app.route("/bytes")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1115why, one step back
1115 def from_bytes():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1116–1118why, one step back
1116 return u"Hällo Wörld".encode("utf-8")
11171118 @app.route("/full_tuple")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1119why, one step back
1119 def from_full_tuple():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1120–1126why, one step back
1120 return (
1121 "Meh",1122 400,1123 {"X-Foo": "Testing", "Content-Type": "text/plain; charset=utf-8"},1124 )11251126 @app.route("/text_headers")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1127why, one step back
1127 def from_text_headers():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1128–1130why, one step back
1128 return "Hello", {"X-Foo": "Test", "Content-Type": "text/plain; charset=utf-8"}
11291130 @app.route("/text_status")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1131why, one step back
1131 def from_text_status():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1132–1134why, one step back
1132 return "Hi, status!", 400
11331134 @app.route("/response_headers")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1135why, one step back
1135 def from_response_headers():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1136–1141why, one step back
1136 return (
1137 flask.Response("Hello world", 404, {"X-Foo": "Baz"}),1138 {"X-Foo": "Bar", "X-Bar": "Foo"},1139 )11401141 @app.route("/response_status")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1142why, one step back
1142 def from_response_status():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1143–1145why, one step back
1143 return app.response_class("Hello world", 400), 500
11441145 @app.route("/wsgi")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1146–1147why, one step back
1146 def from_wsgi():
1147 return NotFound()

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1148–1183why, one step back
1148
1149 assert client.get("/text").data == u"Hällo Wörld".encode("utf-8")1150 assert client.get("/bytes").data == u"Hällo Wörld".encode("utf-8")11511152 rv = client.get("/full_tuple")1153 assert rv.data == b"Meh"1154 assert rv.headers["X-Foo"] == "Testing"1155 assert rv.status_code == 4001156 assert rv.mimetype == "text/plain"11571158 rv = client.get("/text_headers")1159 assert rv.data == b"Hello"1160 assert rv.headers["X-Foo"] == "Test"1161 assert rv.status_code == 2001162 assert rv.mimetype == "text/plain"11631164 rv = client.get("/text_status")1165 assert rv.data == b"Hi, status!"1166 assert rv.status_code == 4001167 assert rv.mimetype == "text/html"11681169 rv = client.get("/response_headers")1170 assert rv.data == b"Hello world"1171 assert rv.headers.getlist("X-Foo") == ["Baz", "Bar"]1172 assert rv.headers["X-Bar"] == "Foo"1173 assert rv.status_code == 40411741175 rv = client.get("/response_status")1176 assert rv.data == b"Hello world"1177 assert rv.status_code == 50011781179 rv = client.get("/wsgi")1180 assert b"Not Found" in rv.data1181 assert rv.status_code == 40411821183

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1184why, one step back
1184def test_response_type_errors():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1185–1188why, one step back
1185 app = flask.Flask(__name__)
1186 app.testing = True11871188 @app.route("/none")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1189why, one step back
1189 def from_none():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1190–1192why, one step back
1190 pass
11911192 @app.route("/small_tuple")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1193why, one step back
1193 def from_small_tuple():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1194–1196why, one step back
1194 return ("Hello",)
11951196 @app.route("/large_tuple")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1197why, one step back
1197 def from_large_tuple():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1198–1200why, one step back
1198 return "Hello", 234, {"X-Foo": "Bar"}, "???"
11991200 @app.route("/bad_type")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1201–1202why, one step back
1201 def from_bad_type():
1202 return True

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1203–1204why, one step back
1203
1204 @app.route("/bad_wsgi")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1205–1206why, one step back
1205 def from_bad_wsgi():
1206 return lambda: None

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1207–1226why, one step back
1207
1208 c = app.test_client()12091210 with pytest.raises(TypeError) as e:1211 c.get("/none")1212 assert "returned None" in str(e)12131214 with pytest.raises(TypeError) as e:1215 c.get("/small_tuple")1216 assert "tuple must have the form" in str(e)12171218 pytest.raises(TypeError, c.get, "/large_tuple")12191220 with pytest.raises(TypeError) as e:1221 c.get("/bad_type")1222 assert "it was a bool" in str(e)12231224 pytest.raises(TypeError, c.get, "/bad_wsgi")12251226

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1227–1228why, one step back
1227def test_make_response(app, req_ctx):
1228 rv = flask.make_response()

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1229–1243why, one step back
1229 assert rv.status_code == 200
1230 assert rv.data == b""1231 assert rv.mimetype == "text/html"12321233 rv = flask.make_response("Awesome")1234 assert rv.status_code == 2001235 assert rv.data == b"Awesome"1236 assert rv.mimetype == "text/html"12371238 rv = flask.make_response("W00t", 404)1239 assert rv.status_code == 4041240 assert rv.data == b"W00t"1241 assert rv.mimetype == "text/html"12421243

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1244why, one step back
1244def test_make_response_with_response_instance(app, req_ctx):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1245–1246why, one step back
1245 rv = flask.make_response(flask.jsonify({"msg": "W00t"}), 400)
1246 assert rv.status_code == 400

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1247why, one step back
1247 assert rv.data == b'{"msg":"W00t"}\n'

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1248–1264why, one step back
1248 assert rv.mimetype == "application/json"
12491250 rv = flask.make_response(flask.Response(""), 400)1251 assert rv.status_code == 4001252 assert rv.data == b""1253 assert rv.mimetype == "text/html"12541255 rv = flask.make_response(1256 flask.Response("", headers={"Content-Type": "text/html"}),1257 400,1258 [("X-Foo", "bar")],1259 )1260 assert rv.status_code == 4001261 assert rv.headers["Content-Type"] == "text/html"1262 assert rv.headers["X-Foo"] == "bar"12631264

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1265–1267why, one step back
1265def test_jsonify_no_prettyprint(app, req_ctx):
1266 app.config.update({"JSONIFY_PRETTYPRINT_REGULAR": False})1267 compressed_msg = b'{"msg":{"submsg":"W00t"},"msg2":"foobar"}\n'

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1268–1270why, one step back
1268 uncompressed_msg = {"msg": {"submsg": "W00t"}, "msg2": "foobar"}
12691270 rv = flask.make_response(flask.jsonify(uncompressed_msg), 200)

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1271why, one step back
1271 assert rv.data == compressed_msg

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1272–1273why, one step back
1272
1273

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1274–1276why, one step back
1274def test_jsonify_prettyprint(app, req_ctx):
1275 app.config.update({"JSONIFY_PRETTYPRINT_REGULAR": True})1276 compressed_msg = {"msg": {"submsg": "W00t"}, "msg2": "foobar"}

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 1277why, one step back
1277 pretty_response = (

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1278why, one step back
1278 b'{\n "msg": {\n "submsg": "W00t"\n }, \n "msg2": "foobar"\n}\n'

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1279–1281why, one step back
1279 )
12801281 rv = flask.make_response(flask.jsonify(compressed_msg), 200)

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1282why, one step back
1282 assert rv.data == pretty_response

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1283–1284why, one step back
1283
1284

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1285why, one step back
1285def test_jsonify_mimetype(app, req_ctx):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1286–1291why, one step back
1286 app.config.update({"JSONIFY_MIMETYPE": "application/vnd.api+json"})
1287 msg = {"msg": {"submsg": "W00t"}}1288 rv = flask.make_response(flask.jsonify(msg), 200)1289 assert rv.mimetype == "application/vnd.api+json"12901291

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1292why, one step back
1292def test_jsonify_args_and_kwargs_check(app, req_ctx):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1293–1297why, one step back
1293 with pytest.raises(TypeError) as e:
1294 flask.jsonify("fake args", kwargs="fake")1295 assert "behavior undefined" in str(e.value)12961297

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1298why, one step back
1298def test_url_generation(app, req_ctx):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 1299why, one step back
1299 @app.route("/hello/<name>", methods=["POST"])

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1300why, one step back
1300 def hello():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1301–1309why, one step back
1301 pass
13021303 assert flask.url_for("hello", name="test x") == "/hello/test%20x"1304 assert (1305 flask.url_for("hello", name="test x", _external=True)1306 == "http://localhost/hello/test%20x"1307 )13081309

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1310–1311why, one step back
1310def test_build_error_handler(app):
1311 # Test base case, a URL which results in a BuildError.

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1312–1314why, one step back
1312 with app.test_request_context():
1313 pytest.raises(BuildError, flask.url_for, "spam")1314

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1315why, one step back
1315 # Verify the error is re-raised if not the current exception.

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 1316why, one step back
1316 try:

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1317why, one step back
1317 with app.test_request_context():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 1318why, one step back
1318 flask.url_for("spam")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1319–1320why, one step back
1319 except BuildError as err:
1320 error = err

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1321–1322why, one step back
1321 try:
1322 raise RuntimeError("Test case where BuildError is not current.")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1323why, one step back
1323 except RuntimeError:

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1324–1325why, one step back
1324 pytest.raises(BuildError, app.handle_url_build_error, error, "spam", {})
1325

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1326why, one step back
1326 # Test a custom handler.

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 1327why, one step back
1327 def handler(error, endpoint, values):

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1328why, one step back
1328 # Just a test.

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1329–1330why, one step back
1329 return "/test_handler/"
1330

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1331why, one step back
1331 app.url_build_error_handlers.append(handler)

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1332–1335why, one step back
1332 with app.test_request_context():
1333 assert flask.url_for("spam") == "/test_handler/"13341335

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1336–1339why, one step back
1336def test_build_error_handler_reraise(app):
1337 # Test a custom handler which reraises the BuildError1338 def handler_raises_build_error(error, endpoint, values):1339 raise error

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 1340why, one step back
1340

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1341why, one step back
1341 app.url_build_error_handlers.append(handler_raises_build_error)

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1342–1346why, one step back
1342
1343 with app.test_request_context():1344 pytest.raises(BuildError, flask.url_for, "not.existing")13451346

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1347–1348why, one step back
1347def test_url_for_passes_special_values_to_build_error_handler(app):
1348 @app.url_build_error_handlers.append

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 1349why, one step back
1349 def handler(error, endpoint, values):

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1350why, one step back
1350 assert values == {

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1351–1361why, one step back
1351 "_external": False,
1352 "_anchor": None,1353 "_method": None,1354 "_scheme": None,1355 }1356 return "handled"13571358 with app.test_request_context():1359 flask.url_for("/")13601361

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1362–1363why, one step back
1362def test_custom_converters(app, client):
1363 from werkzeug.routing import BaseConverter

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 1364why, one step back
1364

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1365–1366why, one step back
1365 class ListConverter(BaseConverter):
1366 def to_python(self, value):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1367–1368why, one step back
1367 return value.split(",")
1368

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1369–1370why, one step back
1369 def to_url(self, value):
1370 base_to_url = super(ListConverter, self).to_url

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1371–1375why, one step back
1371 return ",".join(base_to_url(x) for x in value)
13721373 app.url_map.converters["list"] = ListConverter13741375 @app.route("/<list:args>")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1376why, one step back
1376 def index(args):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1377–1381why, one step back
1377 return "|".join(args)
13781379 assert client.get("/1,2,3").data == b"1|2|3"13801381

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1382why, one step back
1382def test_static_files(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1383–1390why, one step back
1383 rv = client.get("/static/index.html")
1384 assert rv.status_code == 2001385 assert rv.data.strip() == b"<h1>Hello World!</h1>"1386 with app.test_request_context():1387 assert flask.url_for("static", filename="index.html") == "/static/index.html"1388 rv.close()13891390

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1391why, one step back
1391def test_static_url_path():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1392–1401why, one step back
1392 app = flask.Flask(__name__, static_url_path="/foo")
1393 app.testing = True1394 rv = app.test_client().get("/foo/index.html")1395 assert rv.status_code == 2001396 rv.close()13971398 with app.test_request_context():1399 assert flask.url_for("static", filename="index.html") == "/foo/index.html"14001401

Merge pull request #3182 from qil026/issue-3134-url-joinDavid Lordbefore adoptiondbd3840

lines 1402–1412why, one step back
1402def test_static_url_path_with_ending_slash():
1403 app = flask.Flask(__name__, static_url_path="/foo/")1404 app.testing = True1405 rv = app.test_client().get("/foo/index.html")1406 assert rv.status_code == 2001407 rv.close()14081409 with app.test_request_context():1410 assert flask.url_for("static", filename="index.html") == "/foo/index.html"14111412

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1413why, one step back
1413def test_static_route_with_host_matching():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1414–1421why, one step back
1414 app = flask.Flask(__name__, host_matching=True, static_host="example.com")
1415 c = app.test_client()1416 rv = c.get("http://example.com/static/index.html")1417 assert rv.status_code == 2001418 rv.close()1419 with app.test_request_context():1420 rv = flask.url_for("static", filename="index.html", _external=True)1421 assert rv == "http://example.com/static/index.html"

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1422why, one step back
1422 # Providing static_host without host_matching=True should error.

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1423–1424why, one step back
1423 with pytest.raises(Exception):
1424 flask.Flask(__name__, static_host="example.com")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1425why, one step back
1425 # Providing host_matching=True with static_folder but without static_host should error.

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 1426why, one step back
1426 with pytest.raises(Exception):

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1427–1429why, one step back
1427 flask.Flask(__name__, host_matching=True)
1428 # Providing host_matching=True without static_host but with static_folder=None should not error.1429 flask.Flask(__name__, host_matching=True, static_folder=None)

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1430–1431why, one step back
1430
1431

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1432why, one step back
1432def test_request_locals():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 1433why, one step back
1433 assert repr(flask.g) == "<LocalProxy unbound>"

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1434why, one step back
1434 assert not flask.g

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1435–1436why, one step back
1435
1436

Merge pull request #2635 from pallets/feature/server-name-routingDavid Lordbefore adoptionf808c20

line 1437why, one step back
1437def test_test_app_proper_environ():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1438–1446why, one step back
1438 app = flask.Flask(__name__, subdomain_matching=True)
1439 app.config.update(SERVER_NAME="localhost.localdomain:5000")1440 client = app.test_client()14411442 @app.route("/")1443 def index():1444 return "Foo"14451446 @app.route("/", subdomain="foo")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1447why, one step back
1447 def subdomain():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1448–1471why, one step back
1448 return "Foo SubDomain"
14491450 rv = client.get("/")1451 assert rv.data == b"Foo"14521453 rv = client.get("/", "http://localhost.localdomain:5000")1454 assert rv.data == b"Foo"14551456 rv = client.get("/", "https://localhost.localdomain:5000")1457 assert rv.data == b"Foo"14581459 app.config.update(SERVER_NAME="localhost.localdomain")1460 rv = client.get("/", "https://localhost.localdomain")1461 assert rv.data == b"Foo"14621463 try:1464 app.config.update(SERVER_NAME="localhost.localdomain:443")1465 rv = client.get("/", "https://localhost.localdomain")1466 # Werkzeug 0.81467 assert rv.status_code == 4041468 except ValueError as e:1469 # Werkzeug 0.71470 assert str(e) == (1471 "the server name provided "

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1472–1473why, one step back
1472 "('localhost.localdomain:443') does not match the "
1473 "server name from the WSGI environment ('localhost.localdomain')"

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1474–1484why, one step back
1474 )
14751476 try:1477 app.config.update(SERVER_NAME="localhost.localdomain")1478 rv = client.get("/", "http://foo.localhost")1479 # Werkzeug 0.81480 assert rv.status_code == 4041481 except ValueError as e:1482 # Werkzeug 0.71483 assert str(e) == (1484 "the server name provided "

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1485–1486why, one step back
1485 "('localhost.localdomain') does not match the "
1486 "server name from the WSGI environment ('foo.localhost')"

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1487–1492why, one step back
1487 )
14881489 rv = client.get("/", "http://foo.localhost.localdomain")1490 assert rv.data == b"Foo SubDomain"14911492

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1493–1494why, one step back
1493def test_exception_propagation(app, client):
1494 def apprunner(config_key):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1495–1498why, one step back
1495 @app.route("/")
1496 def index():1497 1 // 01498

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1499–1501why, one step back
1499 if config_key is not None:
1500 app.config[config_key] = True1501 with pytest.raises(Exception):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1502–1505why, one step back
1502 client.get("/")
1503 else:1504 assert client.get("/").status_code == 5001505

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1506–1509why, one step back
1506 # we have to run this test in an isolated thread because if the
1507 # debug flag is set to true and an exception happens the context is1508 # not torn down. This causes other tests that run after this fail1509 # when they expect no exception on the stack.

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 1510why, one step back
1510 for config_key in "TESTING", "PROPAGATE_EXCEPTIONS", "DEBUG", None:

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1511–1513why, one step back
1511 t = Thread(target=apprunner, args=(config_key,))
1512 t.start()1513 t.join()

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1514–1530why, one step back
1514
15151516@pytest.mark.parametrize("debug", [True, False])1517@pytest.mark.parametrize("use_debugger", [True, False])1518@pytest.mark.parametrize("use_reloader", [True, False])1519@pytest.mark.parametrize("propagate_exceptions", [None, True, False])1520def test_werkzeug_passthrough_errors(1521 monkeypatch, debug, use_debugger, use_reloader, propagate_exceptions, app1522):1523 rv = {}15241525 # Mocks werkzeug.serving.run_simple method1526 def run_simple_mock(*args, **kwargs):1527 rv["passthrough_errors"] = kwargs.get("passthrough_errors")15281529 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)1530 app.config["PROPAGATE_EXCEPTIONS"] = propagate_exceptions

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1531why, one step back
1531 app.run(debug=debug, use_debugger=use_debugger, use_reloader=use_reloader)

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1532–1533why, one step back
1532
1533

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1534why, one step back
1534def test_max_content_length(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1535–1537why, one step back
1535 app.config["MAX_CONTENT_LENGTH"] = 64
15361537 @app.before_request

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1538why, one step back
1538 def always_first():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1539–1542why, one step back
1539 flask.request.form["myfile"]
1540 assert False15411542 @app.route("/accept", methods=["POST"])

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1543why, one step back
1543 def accept_file():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1544–1546why, one step back
1544 flask.request.form["myfile"]
1545 assert False1546

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1547–1548why, one step back
1547 @app.errorhandler(413)
1548 def catcher(error):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1549–1554why, one step back
1549 return "42"
15501551 rv = client.post("/accept", data={"myfile": "foo" * 100})1552 assert rv.data == b"42"15531554

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1555–1557why, one step back
1555def test_url_processors(app, client):
1556 @app.url_defaults1557 def add_language_code(endpoint, values):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1558–1562why, one step back
1558 if flask.g.lang_code is not None and app.url_map.is_endpoint_expecting(
1559 endpoint, "lang_code"1560 ):1561 values.setdefault("lang_code", flask.g.lang_code)1562

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1563–1564why, one step back
1563 @app.url_value_preprocessor
1564 def pull_lang_code(endpoint, values):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1565–1571why, one step back
1565 flask.g.lang_code = values.pop("lang_code", None)
15661567 @app.route("/<lang_code>/")1568 def index():1569 return flask.url_for("about")15701571 @app.route("/<lang_code>/about")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1572why, one step back
1572 def about():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1573–1575why, one step back
1573 return flask.url_for("something_else")
15741575 @app.route("/foo")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1576why, one step back
1576 def something_else():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1577–1583why, one step back
1577 return flask.url_for("about", lang_code="en")
15781579 assert client.get("/de/").data == b"/de/about"1580 assert client.get("/de/about").data == b"/foo"1581 assert client.get("/foo").data == b"/en/about"15821583

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1584why, one step back
1584def test_inject_blueprint_url_defaults(app):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1585–1586why, one step back
1585 bp = flask.Blueprint("foo.bar.baz", __name__, template_folder="template")
1586

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1587–1588why, one step back
1587 @bp.url_defaults
1588 def bp_defaults(endpoint, values):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1589–1591why, one step back
1589 values["page"] = "login"
15901591 @bp.route("/<page>")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1592why, one step back
1592 def view(page):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1593–1594why, one step back
1593 pass
1594

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1595why, one step back
1595 app.register_blueprint(bp)

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 1596why, one step back
1596

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1597why, one step back
1597 values = dict()

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1598–1599why, one step back
1598 app.inject_url_defaults("foo.bar.baz.view", values)
1599 expected = dict(page="login")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1600why, one step back
1600 assert values == expected

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1601–1604why, one step back
1601
1602 with app.test_request_context("/somepage"):1603 url = flask.url_for("foo.bar.baz.view")1604 expected = "/login"

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1605why, one step back
1605 assert url == expected

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1606–1607why, one step back
1606
1607

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1608why, one step back
1608def test_nonascii_pathinfo(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1609–1616why, one step back
1609 @app.route(u"/киртест")
1610 def index():1611 return "Hello World!"16121613 rv = client.get(u"/киртест")1614 assert rv.data == b"Hello World!"16151616

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1617why, one step back
1617def test_debug_mode_complains_after_first_request(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1618–1623why, one step back
1618 app.debug = True
16191620 @app.route("/")1621 def index():1622 return "Awesome"1623

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1624why, one step back
1624 assert not app.got_first_request

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 1625why, one step back
1625 assert client.get("/").data == b"Awesome"

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1626why, one step back
1626 with pytest.raises(AssertionError) as e:

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1627–1628why, one step back
1627
1628 @app.route("/foo")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1629why, one step back
1629 def broken():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1630–1636why, one step back
1630 return "Meh"
16311632 assert "A setup function was called" in str(e)16331634 app.debug = False16351636 @app.route("/foo")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1637why, one step back
1637 def working():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1638–1643why, one step back
1638 return "Meh"
16391640 assert client.get("/foo").data == b"Meh"1641 assert app.got_first_request16421643

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1644why, one step back
1644def test_before_first_request_functions(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1645–1657why, one step back
1645 got = []
16461647 @app.before_first_request1648 def foo():1649 got.append(42)16501651 client.get("/")1652 assert got == [42]1653 client.get("/")1654 assert got == [42]1655 assert app.got_first_request16561657

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1658why, one step back
1658def test_before_first_request_functions_concurrent(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1659–1662why, one step back
1659 got = []
16601661 @app.before_first_request1662 def foo():

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1663why, one step back
1663 time.sleep(0.2)

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1664–1665why, one step back
1664 got.append(42)
1665

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1666why, one step back
1666 def get_and_assert():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 1667why, one step back
1667 client.get("/")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1668why, one step back
1668 assert got == [42]

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 1669why, one step back
1669

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1670–1673why, one step back
1670 t = Thread(target=get_and_assert)
1671 t.start()1672 get_and_assert()1673 t.join()

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1674–1676why, one step back
1674 assert app.got_first_request
16751676

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1677why, one step back
1677def test_routing_redirect_debugging(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1678–1684why, one step back
1678 app.debug = True
16791680 @app.route("/foo/", methods=["GET", "POST"])1681 def foo():1682 return "success"16831684 with client:

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1685why, one step back
1685 with pytest.raises(AssertionError) as e:

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1686–1698why, one step back
1686 client.post("/foo", data={})
1687 assert "http://localhost/foo/" in str(e)1688 assert ("Make sure to directly send " "your POST-request to this URL") in str(e)16891690 rv = client.get("/foo", data={}, follow_redirects=True)1691 assert rv.data == b"success"16921693 app.debug = False1694 with client:1695 rv = client.post("/foo", data={}, follow_redirects=True)1696 assert rv.data == b"success"16971698

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1699why, one step back
1699def test_route_decorator_custom_endpoint(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1700–1706why, one step back
1700 app.debug = True
17011702 @app.route("/foo/")1703 def foo():1704 return flask.request.endpoint17051706 @app.route("/bar/", endpoint="bar")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1707why, one step back
1707 def for_bar():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1708–1710why, one step back
1708 return flask.request.endpoint
17091710 @app.route("/bar/123", endpoint="123")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1711why, one step back
1711 def for_bar_foo():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1712–1723why, one step back
1712 return flask.request.endpoint
17131714 with app.test_request_context():1715 assert flask.url_for("foo") == "/foo/"1716 assert flask.url_for("bar") == "/bar/"1717 assert flask.url_for("123") == "/bar/123"17181719 assert client.get("/foo/").data == b"foo"1720 assert client.get("/bar/").data == b"bar"1721 assert client.get("/bar/123").data == b"123"17221723

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1724why, one step back
1724def test_preserve_only_once(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1725–1730why, one step back
1725 app.debug = True
17261727 @app.route("/fail")1728 def fail_func():1729 1 // 01730

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1731–1732why, one step back
1731 for x in range(3):
1732 with pytest.raises(ZeroDivisionError):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1733–1734why, one step back
1733 client.get("/fail")
1734

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1735–1740why, one step back
1735 assert flask._request_ctx_stack.top is not None
1736 assert flask._app_ctx_stack.top is not None1737 # implicit appctx disappears too1738 flask._request_ctx_stack.top.pop()1739 assert flask._request_ctx_stack.top is None1740 assert flask._app_ctx_stack.top is None

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1741–1742why, one step back
1741
1742

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1743why, one step back
1743def test_preserve_remembers_exception(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 1744why, one step back
1744 app.debug = True

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1745why, one step back
1745 errors = []

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1746–1751why, one step back
1746
1747 @app.route("/fail")1748 def fail_func():1749 1 // 017501751 @app.route("/success")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1752why, one step back
1752 def success_func():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1753–1755why, one step back
1753 return "Okay"
17541755 @app.teardown_request

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1756–1757why, one step back
1756 def teardown_handler(exc):
1757 errors.append(exc)

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 1758why, one step back
1758

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1759–1760why, one step back
1759 # After this failure we did not yet call the teardown handler
1760 with pytest.raises(ZeroDivisionError):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 1761why, one step back
1761 client.get("/fail")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1762why, one step back
1762 assert errors == []

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 1763why, one step back
1763

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1764why, one step back
1764 # But this request triggers it, and it's an error

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 1765why, one step back
1765 client.get("/success")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1766–1767why, one step back
1766 assert len(errors) == 2
1767 assert isinstance(errors[0], ZeroDivisionError)

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 1768why, one step back
1768

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1769why, one step back
1769 # At this point another request does nothing.

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 1770why, one step back
1770 client.get("/success")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1771–1772why, one step back
1771 assert len(errors) == 3
1772 assert errors[1] is None

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1773–1774why, one step back
1773
1774

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1775why, one step back
1775def test_get_method_on_g(app_ctx):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1776–1777why, one step back
1776 assert flask.g.get("x") is None
1777 assert flask.g.get("x", 11) == 11

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1778why, one step back
1778 flask.g.x = 42

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 1779why, one step back
1779 assert flask.g.get("x") == 42

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1780why, one step back
1780 assert flask.g.x == 42

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1781–1782why, one step back
1781
1782

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1783–1785why, one step back
1783def test_g_iteration_protocol(app_ctx):
1784 flask.g.foo = 231785 flask.g.bar = 42

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1786–1790why, one step back
1786 assert "foo" in flask.g
1787 assert "foos" not in flask.g1788 assert sorted(flask.g) == ["bar", "foo"]17891790

Merge pull request #2635 from pallets/feature/server-name-routingDavid Lordbefore adoptionf808c20

line 1791why, one step back
1791def test_subdomain_basic_support():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1792–1796why, one step back
1792 app = flask.Flask(__name__, subdomain_matching=True)
1793 app.config["SERVER_NAME"] = "localhost.localdomain"1794 client = app.test_client()17951796 @app.route("/")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1797why, one step back
1797 def normal_index():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1798–1800why, one step back
1798 return "normal index"
17991800 @app.route("/", subdomain="test")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1801why, one step back
1801 def test_index():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1802–1810why, one step back
1802 return "test index"
18031804 rv = client.get("/", "http://localhost.localdomain/")1805 assert rv.data == b"normal index"18061807 rv = client.get("/", "http://test.localhost.localdomain/")1808 assert rv.data == b"test index"18091810

Merge pull request #2635 from pallets/feature/server-name-routingDavid Lordbefore adoptionf808c20

line 1811why, one step back
1811def test_subdomain_matching():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1812–1823why, one step back
1812 app = flask.Flask(__name__, subdomain_matching=True)
1813 client = app.test_client()1814 app.config["SERVER_NAME"] = "localhost.localdomain"18151816 @app.route("/", subdomain="<user>")1817 def index(user):1818 return "index for %s" % user18191820 rv = client.get("/", "http://mitsuhiko.localhost.localdomain/")1821 assert rv.data == b"index for mitsuhiko"18221823

Merge pull request #2635 from pallets/feature/server-name-routingDavid Lordbefore adoptionf808c20

line 1824why, one step back
1824def test_subdomain_matching_with_ports():

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1825–1837why, one step back
1825 app = flask.Flask(__name__, subdomain_matching=True)
1826 app.config["SERVER_NAME"] = "localhost.localdomain:3000"1827 client = app.test_client()18281829 @app.route("/", subdomain="<user>")1830 def index(user):1831 return "index for %s" % user18321833 rv = client.get("/", "http://mitsuhiko.localhost.localdomain:3000/")1834 assert rv.data == b"index for mitsuhiko"183518361837@pytest.mark.parametrize("matching", (False, True))

Merge pull request #2635 from pallets/feature/server-name-routingDavid Lordbefore adoptionf808c20

lines 1838–1839why, one step back
1838def test_subdomain_matching_other_name(matching):
1839 app = flask.Flask(__name__, subdomain_matching=matching)

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1840–1846why, one step back
1840 app.config["SERVER_NAME"] = "localhost.localdomain:3000"
1841 client = app.test_client()18421843 @app.route("/")1844 def index():1845 return "", 2041846

Merge pull request #2635 from pallets/feature/server-name-routingDavid Lordbefore adoptionf808c20

line 1847why, one step back
1847 # ip address can't match name

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1848–1850why, one step back
1848 rv = client.get("/", "http://127.0.0.1:3000/")
1849 assert rv.status_code == 404 if matching else 2041850

Merge pull request #2635 from pallets/feature/server-name-routingDavid Lordbefore adoptionf808c20

line 1851why, one step back
1851 # allow all subdomains if matching is disabled

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1852–1855why, one step back
1852 rv = client.get("/", "http://www.localhost.localdomain:3000/")
1853 assert rv.status_code == 404 if matching else 20418541855

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1856why, one step back
1856def test_multi_route_rules(app, client):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1857–1859why, one step back
1857 @app.route("/")
1858 @app.route("/<test>/")1859 def index(test="a"):

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1860why, one step back
1860 return test

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1861–1867why, one step back
1861
1862 rv = client.open("/")1863 assert rv.data == b"a"1864 rv = client.open("/b/")1865 assert rv.data == b"b"18661867

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1868–1870why, one step back
1868def test_multi_route_class_views(app, client):
1869 class View(object):1870 def __init__(self, app):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1871–1874why, one step back
1871 app.add_url_rule("/", "index", self.index)
1872 app.add_url_rule("/<test>/", "index", self.index)18731874 def index(self, test="a"):

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1875why, one step back
1875 return test

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 1876why, one step back
1876

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1877why, one step back
1877 _ = View(app)

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1878–1883why, one step back
1878 rv = client.open("/")
1879 assert rv.data == b"a"1880 rv = client.open("/b/")1881 assert rv.data == b"b"18821883

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1884why, one step back
1884def test_run_defaults(monkeypatch, app):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1885–1891why, one step back
1885 rv = {}
18861887 # Mocks werkzeug.serving.run_simple method1888 def run_simple_mock(*args, **kwargs):1889 rv["result"] = "running..."18901891 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1892why, one step back
1892 app.run()

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1893–1895why, one step back
1893 assert rv["result"] == "running..."
18941895

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1896why, one step back
1896def test_run_server_port(monkeypatch, app):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1897–1899why, one step back
1897 rv = {}
18981899 # Mocks werkzeug.serving.run_simple method

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1900why, one step back
1900 def run_simple_mock(hostname, port, application, *args, **kwargs):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1901–1904why, one step back
1901 rv["result"] = "running on %s:%s ..." % (hostname, port)
19021903 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)1904 hostname, port = "localhost", 8000

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1905why, one step back
1905 app.run(hostname, port, debug=True)

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1906–1917why, one step back
1906 assert rv["result"] == "running on %s:%s ..." % (hostname, port)
190719081909@pytest.mark.parametrize(1910 "host,port,expect_host,expect_port",1911 (1912 (None, None, "pocoo.org", 8080),1913 ("localhost", None, "localhost", 8080),1914 (None, 80, "pocoo.org", 80),1915 ("localhost", 80, "localhost", 80),1916 ),1917)

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1918–1921why, one step back
1918def test_run_from_config(monkeypatch, host, port, expect_host, expect_port, app):
1919 def run_simple_mock(hostname, port, *args, **kwargs):1920 assert hostname == expect_host1921 assert port == expect_port

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1922–1924why, one step back
1922
1923 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)1924 app.config["SERVER_NAME"] = "pocoo.org:8080"

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1925why, one step back
1925 app.run(host, port)

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1926–1927why, one step back
1926
1927

Merge pull request #2693 from davidism/max-cookie-sizeDavid Lordbefore adoptiond8bf589

line 1928why, one step back
1928def test_max_cookie_size(app, client, recwarn):

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1929–1930why, one step back
1929 app.config["MAX_COOKIE_SIZE"] = 100
1930

Merge pull request #2693 from davidism/max-cookie-sizeDavid Lordbefore adoptiond8bf589

lines 1931–1933why, one step back
1931 # outside app context, default to Werkzeug static value,
1932 # which is also the default config1933 response = flask.Response()

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 1934why, one step back
1934 default = flask.Flask.default_config["MAX_COOKIE_SIZE"]

Merge pull request #2693 from davidism/max-cookie-sizeDavid Lordbefore adoptiond8bf589

line 1935why, one step back
1935 assert response.max_cookie_size == default

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

line 1936why, one step back
1936

Merge pull request #2693 from davidism/max-cookie-sizeDavid Lordbefore adoptiond8bf589

lines 1937–1939why, one step back
1937 # inside app context, use app config
1938 with app.app_context():1939 assert flask.Response().max_cookie_size == 100

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1940–1944why, one step back
1940
1941 @app.route("/")1942 def index():1943 r = flask.Response("", status=204)1944 r.set_cookie("foo", "bar" * 100)

Merge pull request #2693 from davidism/max-cookie-sizeDavid Lordbefore adoptiond8bf589

line 1945why, one step back
1945 return r

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1946–1947why, one step back
1946
1947 client.get("/")

Merge pull request #2693 from davidism/max-cookie-sizeDavid Lordbefore adoptiond8bf589

lines 1948–1949why, one step back
1948 assert len(recwarn) == 1
1949 w = recwarn.pop()

Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032

lines 1950–1954why, one step back
1950 assert "cookie is too large" in str(w.message)
19511952 app.config["MAX_COOKIE_SIZE"] = 019531954 client.get("/")

Merge pull request #2693 from davidism/max-cookie-sizeDavid Lordbefore adoptiond8bf589

line 1955why, one step back
1955 assert len(recwarn) == 0