Skip to content
Myr

test_basic.py

This file

Path

tests/test_basic.py

1,944 lines · 52.0 KiB · Python

Last changed by

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

History of this file

Take it

The walk stopped after 200 commits: lines older than 49f3e96 point at it.

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

lines 1–7why, one step 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.

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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"])

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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)

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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():

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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"])

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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",

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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)

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2399 from davidism/docs-secret-keyDavid Lordbefore adoptiond13e41d

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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():

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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"])

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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"])

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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("/")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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"):

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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():

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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/")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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/")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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/")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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/")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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"])

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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"

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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():

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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"

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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("/")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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("/")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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"

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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)

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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"

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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():

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

line 916why, one step back
916

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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)

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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():

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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):

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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):

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2362 from davidism/remove-error-handler-cacheDavid Lordbefore adoptionb80cf05

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

Merge pull request #2362 from davidism/remove-error-handler-cacheDavid Lordbefore adoptionb80cf05

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

Merge pull request #2362 from davidism/remove-error-handler-cacheDavid Lordbefore adoptionb80cf05

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

Merge pull request #2362 from davidism/remove-error-handler-cacheDavid Lordbefore adoptionb80cf05

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

Merge pull request #2362 from davidism/remove-error-handler-cacheDavid Lordbefore adoptionb80cf05

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")

Merge pull request #2362 from davidism/remove-error-handler-cacheDavid Lordbefore adoptionb80cf05

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")

Merge pull request #2362 from davidism/remove-error-handler-cacheDavid Lordbefore adoptionb80cf05

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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:

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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)

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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)

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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 = (

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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)

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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"])

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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:

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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.")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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):

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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):

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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>")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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 #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1403–1410why, one step back
1403 app = flask.Flask(__name__, host_matching=True, static_host="example.com")
1404 c = app.test_client()1405 rv = c.get("http://example.com/static/index.html")1406 assert rv.status_code == 2001407 rv.close()1408 with app.test_request_context():1409 rv = flask.url_for("static", filename="index.html", _external=True)1410 assert rv == "http://example.com/static/index.html"

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1419–1420why, one step back
1419
1420

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1424–1425why, one step back
1424
1425

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

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

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

lines 1427–1435why, one step back
1427 app = flask.Flask(__name__, subdomain_matching=True)
1428 app.config.update(SERVER_NAME="localhost.localdomain:5000")1429 client = app.test_client()14301431 @app.route("/")1432 def index():1433 return "Foo"14341435 @app.route("/", subdomain="foo")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1437–1460why, one step back
1437 return "Foo SubDomain"
14381439 rv = client.get("/")1440 assert rv.data == b"Foo"14411442 rv = client.get("/", "http://localhost.localdomain:5000")1443 assert rv.data == b"Foo"14441445 rv = client.get("/", "https://localhost.localdomain:5000")1446 assert rv.data == b"Foo"14471448 app.config.update(SERVER_NAME="localhost.localdomain")1449 rv = client.get("/", "https://localhost.localdomain")1450 assert rv.data == b"Foo"14511452 try:1453 app.config.update(SERVER_NAME="localhost.localdomain:443")1454 rv = client.get("/", "https://localhost.localdomain")1455 # Werkzeug 0.81456 assert rv.status_code == 4041457 except ValueError as e:1458 # Werkzeug 0.71459 assert str(e) == (1460 "the server name provided "

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1463–1473why, one step back
1463 )
14641465 try:1466 app.config.update(SERVER_NAME="localhost.localdomain")1467 rv = client.get("/", "http://foo.localhost")1468 # Werkzeug 0.81469 assert rv.status_code == 4041470 except ValueError as e:1471 # Werkzeug 0.71472 assert str(e) == (1473 "the server name provided "

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1476–1481why, one step back
1476 )
14771478 rv = client.get("/", "http://foo.localhost.localdomain")1479 assert rv.data == b"Foo SubDomain"14801481

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1484–1487why, one step back
1484 @app.route("/")
1485 def index():1486 1 // 01487

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

lines 1488–1490why, one step back
1488 if config_key is not None:
1489 app.config[config_key] = True1490 with pytest.raises(Exception):

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

lines 1491–1494why, one step back
1491 client.get("/")
1492 else:1493 assert client.get("/").status_code == 5001494

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

lines 1500–1502why, one step back
1500 t = Thread(target=apprunner, args=(config_key,))
1501 t.start()1502 t.join()

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

lines 1503–1519why, one step back
1503
15041505@pytest.mark.parametrize("debug", [True, False])1506@pytest.mark.parametrize("use_debugger", [True, False])1507@pytest.mark.parametrize("use_reloader", [True, False])1508@pytest.mark.parametrize("propagate_exceptions", [None, True, False])1509def test_werkzeug_passthrough_errors(1510 monkeypatch, debug, use_debugger, use_reloader, propagate_exceptions, app1511):1512 rv = {}15131514 # Mocks werkzeug.serving.run_simple method1515 def run_simple_mock(*args, **kwargs):1516 rv["passthrough_errors"] = kwargs.get("passthrough_errors")15171518 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)1519 app.config["PROPAGATE_EXCEPTIONS"] = propagate_exceptions

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1521–1522why, one step back
1521
1522

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1524–1526why, one step back
1524 app.config["MAX_CONTENT_LENGTH"] = 64
15251526 @app.before_request

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1528–1531why, one step back
1528 flask.request.form["myfile"]
1529 assert False15301531 @app.route("/accept", methods=["POST"])

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1533–1535why, one step back
1533 flask.request.form["myfile"]
1534 assert False1535

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1538–1543why, one step back
1538 return "42"
15391540 rv = client.post("/accept", data={"myfile": "foo" * 100})1541 assert rv.data == b"42"15421543

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

lines 1544–1546why, one step back
1544def test_url_processors(app, client):
1545 @app.url_defaults1546 def add_language_code(endpoint, values):

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

lines 1547–1551why, one step back
1547 if flask.g.lang_code is not None and app.url_map.is_endpoint_expecting(
1548 endpoint, "lang_code"1549 ):1550 values.setdefault("lang_code", flask.g.lang_code)1551

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1554–1560why, one step back
1554 flask.g.lang_code = values.pop("lang_code", None)
15551556 @app.route("/<lang_code>/")1557 def index():1558 return flask.url_for("about")15591560 @app.route("/<lang_code>/about")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1562–1564why, one step back
1562 return flask.url_for("something_else")
15631564 @app.route("/foo")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1566–1572why, one step back
1566 return flask.url_for("about", lang_code="en")
15671568 assert client.get("/de/").data == b"/de/about"1569 assert client.get("/de/about").data == b"/foo"1570 assert client.get("/foo").data == b"/en/about"15711572

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1578–1580why, one step back
1578 values["page"] = "login"
15791580 @bp.route("/<page>")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1582–1583why, one step back
1582 pass
1583

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

line 1585why, one step back
1585

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1590–1593why, one step back
1590
1591 with app.test_request_context("/somepage"):1592 url = flask.url_for("foo.bar.baz.view")1593 expected = "/login"

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1595–1596why, one step back
1595
1596

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1598–1605why, one step back
1598 @app.route(u"/киртест")
1599 def index():1600 return "Hello World!"16011602 rv = client.get(u"/киртест")1603 assert rv.data == b"Hello World!"16041605

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1607–1612why, one step back
1607 app.debug = True
16081609 @app.route("/")1610 def index():1611 return "Awesome"1612

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1619–1625why, one step back
1619 return "Meh"
16201621 assert "A setup function was called" in str(e)16221623 app.debug = False16241625 @app.route("/foo")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1627–1632why, one step back
1627 return "Meh"
16281629 assert client.get("/foo").data == b"Meh"1630 assert app.got_first_request16311632

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1634–1646why, one step back
1634 got = []
16351636 @app.before_first_request1637 def foo():1638 got.append(42)16391640 client.get("/")1641 assert got == [42]1642 client.get("/")1643 assert got == [42]1644 assert app.got_first_request16451646

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1648–1651why, one step back
1648 got = []
16491650 @app.before_first_request1651 def foo():

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1653–1654why, one step back
1653 got.append(42)
1654

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

line 1658why, one step back
1658

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

lines 1659–1662why, one step back
1659 t = Thread(target=get_and_assert)
1660 t.start()1661 get_and_assert()1662 t.join()

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

lines 1663–1665why, one step back
1663 assert app.got_first_request
16641665

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1667–1673why, one step back
1667 app.debug = True
16681669 @app.route("/foo/", methods=["GET", "POST"])1670 def foo():1671 return "success"16721673 with client:

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1675–1687why, one step back
1675 client.post("/foo", data={})
1676 assert "http://localhost/foo/" in str(e)1677 assert ("Make sure to directly send " "your POST-request to this URL") in str(e)16781679 rv = client.get("/foo", data={}, follow_redirects=True)1680 assert rv.data == b"success"16811682 app.debug = False1683 with client:1684 rv = client.post("/foo", data={}, follow_redirects=True)1685 assert rv.data == b"success"16861687

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1689–1695why, one step back
1689 app.debug = True
16901691 @app.route("/foo/")1692 def foo():1693 return flask.request.endpoint16941695 @app.route("/bar/", endpoint="bar")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1697–1699why, one step back
1697 return flask.request.endpoint
16981699 @app.route("/bar/123", endpoint="123")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1701–1712why, one step back
1701 return flask.request.endpoint
17021703 with app.test_request_context():1704 assert flask.url_for("foo") == "/foo/"1705 assert flask.url_for("bar") == "/bar/"1706 assert flask.url_for("123") == "/bar/123"17071708 assert client.get("/foo/").data == b"foo"1709 assert client.get("/bar/").data == b"bar"1710 assert client.get("/bar/123").data == b"123"17111712

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1714–1719why, one step back
1714 app.debug = True
17151716 @app.route("/fail")1717 def fail_func():1718 1 // 01719

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1722–1723why, one step back
1722 client.get("/fail")
1723

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

lines 1724–1729why, one step back
1724 assert flask._request_ctx_stack.top is not None
1725 assert flask._app_ctx_stack.top is not None1726 # implicit appctx disappears too1727 flask._request_ctx_stack.top.pop()1728 assert flask._request_ctx_stack.top is None1729 assert flask._app_ctx_stack.top is None

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

lines 1730–1731why, one step back
1730
1731

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1735–1740why, one step back
1735
1736 @app.route("/fail")1737 def fail_func():1738 1 // 017391740 @app.route("/success")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1742–1744why, one step back
1742 return "Okay"
17431744 @app.teardown_request

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

line 1747why, one step back
1747

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

line 1752why, one step back
1752

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

line 1757why, one step back
1757

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1762–1763why, one step back
1762
1763

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

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

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1770–1771why, one step back
1770
1771

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

lines 1772–1774why, one step back
1772def test_g_iteration_protocol(app_ctx):
1773 flask.g.foo = 231774 flask.g.bar = 42

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

lines 1775–1779why, one step back
1775 assert "foo" in flask.g
1776 assert "foos" not in flask.g1777 assert sorted(flask.g) == ["bar", "foo"]17781779

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

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

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

lines 1781–1785why, one step back
1781 app = flask.Flask(__name__, subdomain_matching=True)
1782 app.config["SERVER_NAME"] = "localhost.localdomain"1783 client = app.test_client()17841785 @app.route("/")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1787–1789why, one step back
1787 return "normal index"
17881789 @app.route("/", subdomain="test")

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1791–1799why, one step back
1791 return "test index"
17921793 rv = client.get("/", "http://localhost.localdomain/")1794 assert rv.data == b"normal index"17951796 rv = client.get("/", "http://test.localhost.localdomain/")1797 assert rv.data == b"test index"17981799

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

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

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

lines 1801–1812why, one step back
1801 app = flask.Flask(__name__, subdomain_matching=True)
1802 client = app.test_client()1803 app.config["SERVER_NAME"] = "localhost.localdomain"18041805 @app.route("/", subdomain="<user>")1806 def index(user):1807 return "index for %s" % user18081809 rv = client.get("/", "http://mitsuhiko.localhost.localdomain/")1810 assert rv.data == b"index for mitsuhiko"18111812

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

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

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

lines 1814–1826why, one step back
1814 app = flask.Flask(__name__, subdomain_matching=True)
1815 app.config["SERVER_NAME"] = "localhost.localdomain:3000"1816 client = app.test_client()18171818 @app.route("/", subdomain="<user>")1819 def index(user):1820 return "index for %s" % user18211822 rv = client.get("/", "http://mitsuhiko.localhost.localdomain:3000/")1823 assert rv.data == b"index for mitsuhiko"182418251826@pytest.mark.parametrize("matching", (False, True))

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

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

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

lines 1829–1835why, one step back
1829 app.config["SERVER_NAME"] = "localhost.localdomain:3000"
1830 client = app.test_client()18311832 @app.route("/")1833 def index():1834 return "", 2041835

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

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

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

lines 1837–1839why, one step back
1837 rv = client.get("/", "http://127.0.0.1:3000/")
1838 assert rv.status_code == 404 if matching else 2041839

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

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

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

lines 1841–1844why, one step back
1841 rv = client.get("/", "http://www.localhost.localdomain:3000/")
1842 assert rv.status_code == 404 if matching else 20418431844

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1846–1848why, one step back
1846 @app.route("/")
1847 @app.route("/<test>/")1848 def index(test="a"):

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

line 1849why, one step back
1849 return test

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

lines 1850–1856why, one step back
1850
1851 rv = client.open("/")1852 assert rv.data == b"a"1853 rv = client.open("/b/")1854 assert rv.data == b"b"18551856

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

lines 1857–1859why, one step back
1857def test_multi_route_class_views(app, client):
1858 class View(object):1859 def __init__(self, app):

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

lines 1860–1863why, one step back
1860 app.add_url_rule("/", "index", self.index)
1861 app.add_url_rule("/<test>/", "index", self.index)18621863 def index(self, test="a"):

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

line 1864why, one step back
1864 return test

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

line 1865why, one step back
1865

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1867–1872why, one step back
1867 rv = client.open("/")
1868 assert rv.data == b"a"1869 rv = client.open("/b/")1870 assert rv.data == b"b"18711872

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1874–1880why, one step back
1874 rv = {}
18751876 # Mocks werkzeug.serving.run_simple method1877 def run_simple_mock(*args, **kwargs):1878 rv["result"] = "running..."18791880 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1882–1884why, one step back
1882 assert rv["result"] == "running..."
18831884

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

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

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

lines 1886–1888why, one step back
1886 rv = {}
18871888 # Mocks werkzeug.serving.run_simple method

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

line 1889why, one step back
1889 def run_simple_mock(hostname, port, application, *args, **kwargs):

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

lines 1890–1893why, one step back
1890 rv["result"] = "running on %s:%s ..." % (hostname, port)
18911892 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)1893 hostname, port = "localhost", 8000

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

line 1894why, one step back
1894 app.run(hostname, port, debug=True)

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

lines 1895–1906why, one step back
1895 assert rv["result"] == "running on %s:%s ..." % (hostname, port)
189618971898@pytest.mark.parametrize(1899 "host,port,expect_host,expect_port",1900 (1901 (None, None, "pocoo.org", 8080),1902 ("localhost", None, "localhost", 8080),1903 (None, 80, "pocoo.org", 80),1904 ("localhost", 80, "localhost", 80),1905 ),1906)

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

lines 1907–1910why, one step back
1907def test_run_from_config(monkeypatch, host, port, expect_host, expect_port, app):
1908 def run_simple_mock(hostname, port, *args, **kwargs):1909 assert hostname == expect_host1910 assert port == expect_port

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

lines 1911–1913why, one step back
1911
1912 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)1913 app.config["SERVER_NAME"] = "pocoo.org:8080"

Merge pull request #2353 from grantwwu/patch-1David Lordbefore adoption49f3e96

line 1914why, one step back
1914 app.run(host, port)

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

lines 1915–1916why, one step back
1915
1916

Merge pull request #2693 from davidism/max-cookie-sizeDavid Lordbefore adoptiond8bf589

line 1917why, one step back
1917def test_max_cookie_size(app, client, recwarn):

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

lines 1918–1919why, one step back
1918 app.config["MAX_COOKIE_SIZE"] = 100
1919

Merge pull request #2693 from davidism/max-cookie-sizeDavid Lordbefore adoptiond8bf589

lines 1920–1922why, one step back
1920 # outside app context, default to Werkzeug static value,
1921 # which is also the default config1922 response = flask.Response()

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

line 1923why, one step back
1923 default = flask.Flask.default_config["MAX_COOKIE_SIZE"]

Merge pull request #2693 from davidism/max-cookie-sizeDavid Lordbefore adoptiond8bf589

line 1924why, one step back
1924 assert response.max_cookie_size == default

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

line 1925why, one step back
1925

Merge pull request #2693 from davidism/max-cookie-sizeDavid Lordbefore adoptiond8bf589

lines 1926–1928why, one step back
1926 # inside app context, use app config
1927 with app.app_context():1928 assert flask.Response().max_cookie_size == 100

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

lines 1929–1933why, one step back
1929
1930 @app.route("/")1931 def index():1932 r = flask.Response("", status=204)1933 r.set_cookie("foo", "bar" * 100)

Merge pull request #2693 from davidism/max-cookie-sizeDavid Lordbefore adoptiond8bf589

line 1934why, one step back
1934 return r

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

lines 1935–1936why, one step back
1935
1936 client.get("/")

Merge pull request #2693 from davidism/max-cookie-sizeDavid Lordbefore adoptiond8bf589

lines 1937–1938why, one step back
1937 assert len(recwarn) == 1
1938 w = recwarn.pop()

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

lines 1939–1943why, one step back
1939 assert "cookie is too large" in str(w.message)
19401941 app.config["MAX_COOKIE_SIZE"] = 019421943 client.get("/")

Merge pull request #2693 from davidism/max-cookie-sizeDavid Lordbefore adoptiond8bf589

line 1944why, one step back
1944 assert len(recwarn) == 0