Skip to content
Myr

test_basic.py

This file

Path

tests/test_basic.py

1,972 lines · 53.0 KiB · Python

Last changed by

Merge pull request #3684 from MLH-Fellowship/3628-duplicate-headersDavid Lordbefore adoption2fa8eb3

History of this file

Take it

The walk stopped after 200 commits: lines older than 21b0aa6 point at it.

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

line 1why, one step back
1import re

Merge pull request #3195 from eruvanos/json_support_dataclassDavid Lordbefore adoptionb0185a6

line 2why, one step back
2import sys

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

lines 3–9why, one step back
3import time
4import uuid5from datetime import datetime6from threading import Thread78import pytest9import werkzeug.serving

Merge pull request #3246 from pallets/reorder-importsDavid Lordbefore adoption3db4697

lines 10–12why, one step back
10from werkzeug.exceptions import BadRequest
11from werkzeug.exceptions import Forbidden12from werkzeug.exceptions import NotFound

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

lines 13–19why, one step back
13from werkzeug.http import parse_date
14from werkzeug.routing import BuildError1516import flask171819def test_options_work(app, client):

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

lines 20–28why, one step back
20 @app.route("/", methods=["GET", "POST"])
21 def index():22 return "Hello World"2324 rv = client.open("/", method="OPTIONS")25 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS", "POST"]26 assert rv.data == b""2728

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 30–34why, one step back
30 @app.route("/", methods=["GET", "POST"])
31 def index():32 return "Hello World"3334 @app.route("/", methods=["PUT"])

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 36–41why, one step back
36 return "Aha!"
3738 rv = client.open("/", method="OPTIONS")39 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS", "POST", "PUT"]4041

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 43–47why, one step back
43 app = flask.Flask(__name__)
4445 def index():46 return "Hello World!"47

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 49–57why, one step back
49 app.route("/")(index)
50 rv = app.test_client().open("/", method="OPTIONS")51 assert rv.status_code == 4055253 app = flask.Flask(__name__)5455 def index2():56 return "Hello World!"57

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 59–63why, one step back
59 app.route("/", methods=["OPTIONS"])(index2)
60 rv = app.test_client().open("/", method="OPTIONS")61 assert sorted(rv.allow) == ["OPTIONS"]6263

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 65–71why, one step back
65 def index():
66 return flask.request.method6768 def more():69 return flask.request.method7071 app.add_url_rule("/", view_func=index, provide_automatic_options=False)

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 73–83why, one step back
73 "/more",
74 view_func=more,75 methods=["GET", "POST"],76 provide_automatic_options=False,77 )78 assert client.get("/").data == b"GET"7980 rv = client.post("/")81 assert rv.status_code == 40582 assert sorted(rv.allow) == ["GET", "HEAD"]83

Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374

line 84why, one step back
84 rv = client.open("/", method="OPTIONS")

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

lines 85–96why, one step back
85 assert rv.status_code == 405
8687 rv = client.head("/")88 assert rv.status_code == 20089 assert not rv.data # head truncates90 assert client.post("/more").data == b"POST"91 assert client.get("/more").data == b"GET"9293 rv = client.delete("/more")94 assert rv.status_code == 40595 assert sorted(rv.allow) == ["GET", "HEAD", "POST"]96

Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374

line 97why, one step back
97 rv = client.open("/more", method="OPTIONS")

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

lines 98–100why, one step back
98 assert rv.status_code == 405
99100

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 102–123why, one step back
102 @app.route("/")
103 def index():104 return flask.request.method105106 @app.route("/more", methods=["GET", "POST"])107 def more():108 return flask.request.method109110 assert client.get("/").data == b"GET"111 rv = client.post("/")112 assert rv.status_code == 405113 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS"]114 rv = client.head("/")115 assert rv.status_code == 200116 assert not rv.data # head truncates117 assert client.post("/more").data == b"POST"118 assert client.get("/more").data == b"GET"119 rv = client.delete("/more")120 assert rv.status_code == 405121 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS", "POST"]122123

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 126–128why, one step back
126
127 @app.route("/", methods="GET POST")128 def index():

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 130–131why, one step back
130
131

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 134–140why, one step back
134
135 def index():136 return flask.request.method137138 def more():139 return flask.request.method140

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

lines 141–142why, one step back
141 def options():
142 return random_uuid4

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

lines 143–146why, one step back
143
144 app.add_url_rule("/", "index", index)145 app.add_url_rule("/more", "more", more, methods=["GET", "POST"])146

Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86

lines 147–148why, one step back
147 # Issue 1288: Test that automatic options are not added
148 # when non-uppercase 'options' in methods

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

lines 149–164why, one step back
149 app.add_url_rule("/options", "options", options, methods=["options"])
150151 assert client.get("/").data == b"GET"152 rv = client.post("/")153 assert rv.status_code == 405154 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS"]155 rv = client.head("/")156 assert rv.status_code == 200157 assert not rv.data # head truncates158 assert client.post("/more").data == b"POST"159 assert client.get("/more").data == b"GET"160 rv = client.delete("/more")161 assert rv.status_code == 405162 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS", "POST"]163 rv = client.open("/options", method="OPTIONS")164 assert rv.status_code == 200

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 166–167why, one step back
166
167

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 169–187why, one step back
169 from werkzeug.routing import Submount, Rule
170171 app.url_map.add(172 Submount("/foo", [Rule("/bar", endpoint="bar"), Rule("/", endpoint="index")])173 )174175 def bar():176 return "bar"177178 def index():179 return "index"180181 app.view_functions["bar"] = bar182 app.view_functions["index"] = index183184 assert client.get("/foo/").data == b"index"185 assert client.get("/foo/bar").data == b"bar"186187

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 189–206why, one step back
189 from werkzeug.routing import Submount, Rule
190191 app.url_map.add(192 Submount("/foo", [Rule("/bar", endpoint="bar"), Rule("/", endpoint="index")])193 )194195 @app.endpoint("bar")196 def bar():197 return "bar"198199 @app.endpoint("index")200 def index():201 return "index"202203 assert client.get("/foo/").data == b"index"204 assert client.get("/foo/bar").data == b"bar"205206

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 210–213why, one step back
210 assert not flask.session.accessed
211 assert not flask.session.modified212 flask.session["value"] = flask.request.form["value"]213 assert flask.session.accessed

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 215–223why, one step back
215 return "value set"
216217 @app.route("/get")218 def get():219 assert not flask.session.accessed220 assert not flask.session.modified221 v = flask.session.get("value", "None")222 assert flask.session.accessed223 assert not flask.session.modified

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

line 224why, one step back
224 return v

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

lines 225–229why, one step back
225
226 assert client.post("/set", data={"value": "42"}).data == b"value set"227 assert client.get("/get").data == b"42"228229

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 231–242why, one step back
231 app.config.update(SERVER_NAME="example.com")
232233 @app.route("/")234 def index():235 flask.session["testing"] = 42236 return "Hello World"237238 rv = client.get("/", "http://example.com/")239 assert "domain=.example.com" in rv.headers["set-cookie"].lower()240 assert "httponly" in rv.headers["set-cookie"].lower()241242

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 244–255why, one step back
244 app.config.update(SERVER_NAME="example.com:8080")
245246 @app.route("/")247 def index():248 flask.session["testing"] = 42249 return "Hello World"250251 rv = client.get("/", "http://example.com:8080/")252 assert "domain=.example.com" in rv.headers["set-cookie"].lower()253 assert "httponly" in rv.headers["set-cookie"].lower()254255

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 257–269why, one step back
257 app.config.update(SERVER_NAME="example.com:8080", APPLICATION_ROOT="/foo")
258259 @app.route("/")260 def index():261 flask.session["testing"] = 42262 return "Hello World"263264 rv = client.get("/", "http://example.com:8080/foo")265 assert "domain=example.com" in rv.headers["set-cookie"].lower()266 assert "path=/foo" in rv.headers["set-cookie"].lower()267 assert "httponly" in rv.headers["set-cookie"].lower()268269

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

line 270why, one step back
270def test_session_using_application_root(app, client):

Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374

line 271why, one step back
271 class PrefixPathMiddleware:

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

lines 272–274why, one step back
272 def __init__(self, app, prefix):
273 self.app = app274 self.prefix = prefix

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

line 275why, one step back
275

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 279–291why, one step back
279
280 app.wsgi_app = PrefixPathMiddleware(app.wsgi_app, "/bar")281 app.config.update(APPLICATION_ROOT="/bar")282283 @app.route("/")284 def index():285 flask.session["testing"] = 42286 return "Hello World"287288 rv = client.get("/", "http://example.com:8080/")289 assert "path=/bar" in rv.headers["set-cookie"].lower()290291

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 293–296why, one step back
293 app.config.update(
294 SERVER_NAME="www.example.com:8080",295 APPLICATION_ROOT="/test",296 SESSION_COOKIE_DOMAIN=".example.com",

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

lines 297–298why, one step back
297 SESSION_COOKIE_HTTPONLY=False,
298 SESSION_COOKIE_SECURE=True,

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

lines 299–316why, one step back
299 SESSION_COOKIE_SAMESITE="Lax",
300 SESSION_COOKIE_PATH="/",301 )302303 @app.route("/")304 def index():305 flask.session["testing"] = 42306 return "Hello World"307308 rv = client.get("/", "http://www.example.com:8080/test/")309 cookie = rv.headers["set-cookie"].lower()310 assert "domain=.example.com" in cookie311 assert "path=/" in cookie312 assert "secure" in cookie313 assert "httponly" not in cookie314 assert "samesite" in cookie315316

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 318–324why, one step back
318 @app.route("/")
319 def index():320 flask.session["testing"] = 42321 return "Hello World"322323 app.config.update(SESSION_COOKIE_SAMESITE="invalid")324

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 326–327why, one step back
326 client.get("/")
327

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 329–343why, one step back
329 rv = client.get("/")
330 cookie = rv.headers["set-cookie"].lower()331 assert "samesite" not in cookie332333 app.config.update(SESSION_COOKIE_SAMESITE="Strict")334 rv = client.get("/")335 cookie = rv.headers["set-cookie"].lower()336 assert "samesite=strict" in cookie337338 app.config.update(SESSION_COOKIE_SAMESITE="Lax")339 rv = client.get("/")340 cookie = rv.headers["set-cookie"].lower()341 assert "samesite=lax" in cookie342343

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 345–354why, one step back
345 app.config.update(SERVER_NAME="localhost:5000")
346347 @app.route("/")348 def index():349 flask.session["testing"] = 42350 return "testing"351352 rv = client.get("/", "http://localhost:5000/")353 assert "domain" not in rv.headers["set-cookie"].lower()354 w = recwarn.pop(UserWarning)

Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374

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

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

lines 356–357why, one step back
356
357

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 359–371why, one step back
359 app.config.update(SERVER_NAME="127.0.0.1:5000")
360361 @app.route("/")362 def index():363 flask.session["testing"] = 42364 return "testing"365366 rv = client.get("/", "http://127.0.0.1:5000/")367 assert "domain=127.0.0.1" in rv.headers["set-cookie"].lower()368 w = recwarn.pop(UserWarning)369 assert "cookie domain is an IP" in str(w.message)370371

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

line 374why, one step back
374

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 377–384why, one step back
377 assert e.value.args and "session is unavailable" in e.value.args[0]
378379 with app.test_request_context():380 assert flask.session.get("missing_key") is None381 expect_exception(flask.session.__setitem__, "foo", 42)382 expect_exception(flask.session.pop, "foo")383384

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 387–390why, one step back
387
388 @app.route("/")389 def index():390 flask.session["test"] = 42

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 392–395why, one step back
392 return ""
393394 @app.route("/test")395 def test():

Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374

line 396why, one step back
396 return str(flask.session.permanent)

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

lines 397–400why, one step back
397
398 rv = client.get("/")399 assert "set-cookie" in rv.headers400 match = re.search(r"(?i)\bexpires=([^;]+)", rv.headers["set-cookie"])

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

lines 401–405why, one step back
401 expires = parse_date(match.group())
402 expected = datetime.utcnow() + app.permanent_session_lifetime403 assert expires.year == expected.year404 assert expires.month == expected.month405 assert expires.day == expected.day

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

lines 406–409why, one step back
406
407 rv = client.get("/test")408 assert rv.data == b"True"409

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

line 410why, one step back
410 permanent = False

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 415–416why, one step back
415
416

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 420–430why, one step back
420 flask.session["foo"] = 42
421 return response422423 @app.route("/")424 def dump_session_contents():425 return repr(flask.session.get("foo"))426427 assert client.get("/").data == b"None"428 assert client.get("/").data == b"42"429430

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 434–448why, one step back
434
435 @app.route("/")436 def dump_session_contents():437 flask.session["t"] = (1, 2, 3)438 flask.session["b"] = b"\xff"439 flask.session["m"] = flask.Markup("<html>")440 flask.session["u"] = the_uuid441 flask.session["d"] = now442 flask.session["t_tag"] = {" t": "not-a-tuple"}443 flask.session["di_t_tag"] = {" t__": "not-a-tuple"}444 flask.session["di_tag"] = {" di": "not-a-dict"}445 return "", 204446447 with client:448 client.get("/")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 450–461why, one step back
450 assert s["t"] == (1, 2, 3)
451 assert type(s["b"]) == bytes452 assert s["b"] == b"\xff"453 assert type(s["m"]) == flask.Markup454 assert s["m"] == flask.Markup("<html>")455 assert s["u"] == the_uuid456 assert s["d"] == now457 assert s["t_tag"] == {" t": "not-a-tuple"}458 assert s["di_t_tag"] == {" t__": "not-a-tuple"}459 assert s["di_tag"] == {" di": "not-a-dict"}460461

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 463–465why, one step back
463 is_permanent = True
464465 @app.route("/bump")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 477–482why, one step back
477 assert c.get("/bump").data == b"1"
478 assert c.get("/bump").data == b"2"479 assert c.get("/bump").data == b"3"480481 rv = c.get("/read")482 set_cookie = rv.headers.get("set-cookie")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 484–487why, one step back
484 assert rv.data == b"3"
485486 is_permanent = True487 app.config["SESSION_REFRESH_EACH_REQUEST"] = True

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 489–502why, one step back
489
490 is_permanent = True491 app.config["SESSION_REFRESH_EACH_REQUEST"] = False492 run_test(expect_header=False)493494 is_permanent = False495 app.config["SESSION_REFRESH_EACH_REQUEST"] = True496 run_test(expect_header=False)497498 is_permanent = False499 app.config["SESSION_REFRESH_EACH_REQUEST"] = False500 run_test(expect_header=False)501502

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 506–513why, one step back
506 flask.session["test"] = "test"
507 return ""508509 @app.route("/get")510 def get():511 return flask.session.get("test")512513 @app.route("/getitem")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 515–517why, one step back
515 return flask.session["test"]
516517 @app.route("/setdefault")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 523–528why, one step back
523 response = flask.Response()
524 response.vary.add("Cookie")525 flask.session["test"] = "test"526 return response527528 @app.route("/vary-header-set")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 530–535why, one step back
530 response = flask.Response()
531 response.vary.update(("Accept-Encoding", "Accept-Language"))532 flask.session["test"] = "test"533 return response534535 @app.route("/no-vary-header")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 537–539why, one step back
537 return ""
538539 def expect(path, header_value="Cookie"):

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

line 541why, one step back
541

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 544–557why, one step back
544 assert len(rv.headers.get_all("Vary")) == 1
545 assert rv.headers["Vary"] == header_value546 else:547 assert "Vary" not in rv.headers548549 expect("/set")550 expect("/get")551 expect("/getitem")552 expect("/setdefault")553 expect("/vary-cookie-header-set")554 expect("/vary-header-set", "Accept-Encoding, Accept-Language, Cookie")555 expect("/no-vary-header", None)556557

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 564–566why, one step back
564 assert list(flask.get_flashed_messages()) == ["Zap", "Zip"]
565566

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

lines 567–572why, one step back
567def test_extended_flashing(app):
568 # Be sure app.testing=True below, else tests can fail silently.569 #570 # Specifically, if app.testing is not set to True, the AssertionErrors571 # in the view functions will cause a 500 response to the test client572 # instead of propagating exceptions.

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

lines 573–575why, one step back
573
574 @app.route("/")575 def index():

Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374

lines 576–578why, one step back
576 flask.flash("Hello World")
577 flask.flash("Hello World", "error")578 flask.flash(flask.Markup("<em>Testing</em>"), "warning")

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

lines 579–582why, one step back
579 return ""
580581 @app.route("/test/")582 def test():

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

line 584why, one step back
584 assert list(messages) == [

Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374

lines 585–587why, one step back
585 "Hello World",
586 "Hello World",587 flask.Markup("<em>Testing</em>"),

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

lines 588–591why, one step back
588 ]
589 return ""590591 @app.route("/test_with_categories/")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

lines 592–594why, one step back
592 def test_with_categories():
593 messages = flask.get_flashed_messages(with_categories=True)594 assert len(messages) == 3

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

line 595why, one step back
595 assert list(messages) == [

Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374

lines 596–598why, one step back
596 ("message", "Hello World"),
597 ("error", "Hello World"),598 ("warning", flask.Markup("<em>Testing</em>")),

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

lines 599–602why, one step back
599 ]
600 return ""601602 @app.route("/test_filter/")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 604–606why, one step back
604 messages = flask.get_flashed_messages(
605 category_filter=["message"], with_categories=True606 )

Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374

line 607why, one step back
607 assert list(messages) == [("message", "Hello World")]

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

lines 608–610why, one step back
608 return ""
609610 @app.route("/test_filters/")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 612–615why, one step back
612 messages = flask.get_flashed_messages(
613 category_filter=["message", "warning"], with_categories=True614 )615 assert list(messages) == [

Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374

lines 616–617why, one step back
616 ("message", "Hello World"),
617 ("warning", flask.Markup("<em>Testing</em>")),

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

lines 618–621why, one step back
618 ]
619 return ""620621 @app.route("/test_filters_without_returning_categories/")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374

lines 625–626why, one step back
625 assert messages[0] == "Hello World"
626 assert messages[1] == flask.Markup("<em>Testing</em>")

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

lines 627–628why, one step back
627 return ""
628

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 630–647why, one step back
630
631 client = app.test_client()632 client.get("/")633 client.get("/test_with_categories/")634635 client = app.test_client()636 client.get("/")637 client.get("/test_filter/")638639 client = app.test_client()640 client.get("/")641 client.get("/test_filters/")642643 client = app.test_client()644 client.get("/")645 client.get("/test_filters_without_returning_categories/")646647

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 649–672why, one step back
649 evts = []
650651 @app.before_request652 def before_request():653 evts.append("before")654655 @app.after_request656 def after_request(response):657 response.data += b"|after"658 evts.append("after")659 return response660661 @app.route("/")662 def index():663 assert "before" in evts664 assert "after" not in evts665 return "request"666667 assert "after" not in evts668 rv = client.get("/").data669 assert "after" in evts670 assert rv == b"request|after"671672

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 674–676why, one step back
674 evts = []
675676 @app.before_request

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 679–680why, one step back
679
680 @app.before_request

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

lines 681–683why, one step back
681 def before_request2():
682 evts.append(2)683 return "hello"

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

lines 684–685why, one step back
684
685 @app.before_request

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

lines 686–688why, one step back
686 def before_request3():
687 evts.append(3)688 return "bye"

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

lines 689–692why, one step back
689
690 @app.route("/")691 def index():692 evts.append("index")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 694–696why, one step back
694
695 rv = client.get("/").data.strip()696 assert rv == b"hello"

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 698–699why, one step back
698
699

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

line 706why, one step back
706 return response

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

lines 707–710why, one step back
707
708 return "Test"709710 resp = client.get("/")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 712–714why, one step back
712 assert resp.headers["X-Foo"] == "a header"
713714

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 716–732why, one step back
716 called = []
717718 @app.teardown_request719 def teardown_request(exc):720 called.append(True)721 return "Ignored"722723 @app.route("/")724 def root():725 return "Response"726727 rv = client.get("/")728 assert rv.status_code == 200729 assert b"Response" in rv.data730 assert len(called) == 1731732

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 734–750why, one step back
734 called = []
735736 @app.teardown_request737 def teardown_request(exc):738 called.append(True)739 return "Ignored"740741 @app.route("/")742 def root():743 return "Response"744745 rv = client.get("/")746 assert rv.status_code == 200747 assert b"Response" in rv.data748 assert len(called) == 1749750

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 752–755why, one step back
752 called = []
753 app.testing = False754755 @app.teardown_request

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 757–763why, one step back
757 assert type(exc) == ZeroDivisionError
758 called.append(True)759 # This raises a new error and blows away sys.exc_info(), so we can760 # test that all teardown_requests get passed the same original761 # exception.762 try:763 raise TypeError()

Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86

line 764why, one step back
764 except Exception:

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

lines 765–767why, one step back
765 pass
766767 @app.teardown_request

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 769–775why, one step back
769 assert type(exc) == ZeroDivisionError
770 called.append(True)771 # This raises a new error and blows away sys.exc_info(), so we can772 # test that all teardown_requests get passed the same original773 # exception.774 try:775 raise TypeError()

Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86

line 776why, one step back
776 except Exception:

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

lines 777–779why, one step back
777 pass
778779 @app.route("/")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 781–785why, one step back
781 1 // 0
782783 rv = client.get("/")784 assert rv.status_code == 500785 assert b"Internal Server Error" in rv.data

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 787–788why, one step back
787
788

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 790–792why, one step back
790 called = []
791792 @app.before_request

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 795–796why, one step back
795
796 @app.before_request

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 799–800why, one step back
799
800 @app.after_request

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 803–805why, one step back
803 return response
804805 @app.after_request

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 808–810why, one step back
808 return response
809810 @app.teardown_request

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 813–814why, one step back
813
814 @app.teardown_request

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 817–823why, one step back
817
818 @app.route("/")819 def index():820 return "42"821822 rv = client.get("/")823 assert rv.data == b"42"

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 825–826why, one step back
825
826

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 828–830why, one step back
828 app.testing = False
829830 @app.errorhandler(404)

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 832–837why, one step back
832 return "not found", 404
833834 @app.errorhandler(500)835 def internal_server_error(e):836 return "internal server error", 500837

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 840–846why, one step back
840 return "forbidden", 403
841842 @app.route("/")843 def index():844 flask.abort(404)845846 @app.route("/error")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 848–850why, one step back
848 1 // 0
849850 @app.route("/forbidden")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 852–860why, one step back
852 flask.abort(403)
853854 rv = client.get("/")855 assert rv.status_code == 404856 assert rv.data == b"not found"857 rv = client.get("/error")858 assert rv.status_code == 500859 assert b"internal server error" == rv.data860 rv = client.get("/forbidden")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 862–864why, one step back
862 assert b"forbidden" == rv.data
863864

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 867–871why, one step back
867 app.register_error_handler(999, lambda e: ("999", 999))
868869 assert "Use a subclass" in exc_info.value.args[0]870871

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 873–883why, one step back
873 app.testing = False
874875 @app.errorhandler(500)876 def internal_server_error(e):877 return "internal server error", 500878879 @app.route("/")880 def broken_func():881 1 // 0882883 @app.after_request

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

line 886why, one step back
886 return resp

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

lines 887–892why, one step back
887
888 resp = client.get("/")889 assert resp.mimetype == "text/x-special"890 assert resp.data == b"internal server error"891892

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 894–897why, one step back
894 app.testing = False
895896 @app.route("/")897 def broken_func():

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

line 899why, one step back
899

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 901–902why, one step back
901 client.get("/")
902

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

lines 903–905why, one step back
903 ctx = flask._request_ctx_stack.top
904 assert ctx.preserved905 assert type(ctx._preserved_exc) is KeyboardInterrupt

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

lines 906–907why, one step back
906
907

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 911–913why, one step back
911 flask.g.something = "value"
912913 @app.errorhandler(404)

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 916–921why, one step back
916
917 rv = client.get("/")918 assert rv.status_code == 404919 assert rv.data == b"value"920921

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 924–925why, one step back
924 pass
925

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

lines 926–928why, one step back
926 @app.errorhandler(MyException)
927 def handle_my_exception(e):928 assert isinstance(e, MyException)

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

lines 929–932why, one step back
929 return "42"
930931 @app.route("/")932 def index():

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 934–937why, one step back
934
935 assert client.get("/").data == b"42"936937

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 945–946why, one step back
945 return "banana"
946

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86

line 948why, one step back
948 def handle_403(e):

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

lines 949–950why, one step back
949 assert not isinstance(e, ForbiddenSubclass)
950 assert isinstance(e, Forbidden)

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

lines 951–953why, one step back
951 return "apple"
952953 @app.route("/1")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

lines 954–955why, one step back
954 def index1():
955 raise ForbiddenSubclass()

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

lines 956–961why, one step back
956
957 @app.route("/2")958 def index2():959 flask.abort(403)960961 @app.route("/3")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

lines 962–963why, one step back
962 def index3():
963 raise Forbidden()

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

lines 964–969why, one step back
964
965 assert client.get("/1").data == b"banana"966 assert client.get("/2").data == b"apple"967 assert client.get("/3").data == b"apple"968969

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 972–973why, one step back
972 pass
973

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 975–976why, one step back
975 pass
976

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 978–979why, one step back
978 pass
979

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 982–983why, one step back
982 return "E2"
983

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 986–988why, one step back
986 return "Exception"
987988 @app.route("/E1")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

lines 989–990why, one step back
989 def raise_e1():
990 raise E1

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

lines 993–994why, one step back
993 def raise_e3():
994 raise E3

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

lines 995–1002why, one step back
995
996 rv = client.get("/E1")997 assert rv.data == b"Exception"998999 rv = client.get("/E3")1000 assert rv.data == b"E2"10011002

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1004–1008why, one step back
1004 @app.route("/key")
1005 def fail():1006 flask.request.form["missing_key"]10071008 @app.route("/abort")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1011–1018why, one step back
1011
1012 rv = client.get("/key")1013 assert rv.status_code == 4001014 assert b"missing_key" not in rv.data1015 rv = client.get("/abort")1016 assert rv.status_code == 40010171018 app.debug = True

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1022–1027why, one step back
1022 assert "missing_key" in e.value.get_description()
1023 rv = client.get("/abort")1024 assert rv.status_code == 40010251026 app.debug = False1027 app.config["TRAP_BAD_REQUEST_ERRORS"] = True

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1031–1033why, one step back
1031 client.get("/abort")
10321033

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1035–1040why, one step back
1035 app.config["TRAP_HTTP_EXCEPTIONS"] = True
10361037 @app.route("/fail")1038 def fail():1039 flask.abort(404)1040

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1042–1044why, one step back
1042 client.get("/fail")
10431044

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1046–1049why, one step back
1046 app.testing = False
10471048 @app.before_request1049 def before_request():

Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86

line 1050why, one step back
1050 if _trigger == "before":

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

lines 1051–1054why, one step back
1051 1 // 0
10521053 @app.after_request1054 def after_request(response):

Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86

line 1055why, one step back
1055 if _trigger == "after":

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

lines 1056–1066why, one step back
1056 1 // 0
1057 return response10581059 @app.route("/")1060 def index():1061 return "Foo"10621063 @app.errorhandler(500)1064 def internal_server_error(e):1065 return "Hello Server Error", 5001066

Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86

line 1067why, one step back
1067 for _trigger in "before", "after":

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

line 1068why, one step back
1068 rv = client.get("/")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1070–1072why, one step back
1070 assert rv.data == b"Hello Server Error"
10711072

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1075–1081why, one step back
1075
1076 app.debug = True10771078 @app.route("/fail", methods=["POST"])1079 def index():1080 return flask.request.files["foo"].filename1081

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

line 1085why, one step back
1085 with client:

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374

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

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

lines 1090–1091why, one step back
1090
1091

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374

line 1095why, one step back
1095 return "Hällo Wörld"

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

lines 1096–1097why, one step back
1096
1097 @app.route("/bytes")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374

line 1099why, one step back
1099 return "Hällo Wörld".encode()

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

lines 1100–1101why, one step back
1100
1101 @app.route("/full_tuple")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1103–1109why, one step back
1103 return (
1104 "Meh",1105 400,1106 {"X-Foo": "Testing", "Content-Type": "text/plain; charset=utf-8"},1107 )11081109 @app.route("/text_headers")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1115–1117why, one step back
1115 return "Hi, status!", 400
11161117 @app.route("/response_headers")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

line 1119why, one step back
1119 return (

Merge pull request #3684 from MLH-Fellowship/3628-duplicate-headersDavid Lordbefore adoption2fa8eb3

lines 1120–1123why, one step back
1120 flask.Response(
1121 "Hello world", 404, {"Content-Type": "text/html", "X-Foo": "Baz"}1122 ),1123 {"Content-Type": "text/plain", "X-Foo": "Bar", "X-Bar": "Foo"},

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

lines 1124–1126why, one step back
1124 )
11251126 @app.route("/response_status")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1128–1130why, one step back
1128 return app.response_class("Hello world", 400), 500
11291130 @app.route("/wsgi")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

lines 1131–1132why, one step back
1131 def from_wsgi():
1132 return NotFound()

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

line 1133why, one step back
1133

Merge pull request #3229 from lordmauve/style-fixDavid Lordbefore adoption240e398

line 1134why, one step back
1134 @app.route("/dict")

Merge pull request #3111 from pgjones/masterDavid Lordbefore adoption855d59b

lines 1135–1136why, one step back
1135 def from_dict():
1136 return {"foo": "bar"}, 201

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

line 1137why, one step back
1137

Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374

lines 1138–1139why, one step back
1138 assert client.get("/text").data == "Hällo Wörld".encode()
1139 assert client.get("/bytes").data == "Hällo Wörld".encode()

Merge pull request #3111 from pgjones/masterDavid Lordbefore adoption855d59b

line 1140why, one step back
1140

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

lines 1141–1159why, one step back
1141 rv = client.get("/full_tuple")
1142 assert rv.data == b"Meh"1143 assert rv.headers["X-Foo"] == "Testing"1144 assert rv.status_code == 4001145 assert rv.mimetype == "text/plain"11461147 rv = client.get("/text_headers")1148 assert rv.data == b"Hello"1149 assert rv.headers["X-Foo"] == "Test"1150 assert rv.status_code == 2001151 assert rv.mimetype == "text/plain"11521153 rv = client.get("/text_status")1154 assert rv.data == b"Hi, status!"1155 assert rv.status_code == 4001156 assert rv.mimetype == "text/html"11571158 rv = client.get("/response_headers")1159 assert rv.data == b"Hello world"

Merge pull request #3684 from MLH-Fellowship/3628-duplicate-headersDavid Lordbefore adoption2fa8eb3

lines 1160–1161why, one step back
1160 assert rv.content_type == "text/plain"
1161 assert rv.headers.getlist("X-Foo") == ["Bar"]

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

lines 1162–1171why, one step back
1162 assert rv.headers["X-Bar"] == "Foo"
1163 assert rv.status_code == 40411641165 rv = client.get("/response_status")1166 assert rv.data == b"Hello world"1167 assert rv.status_code == 50011681169 rv = client.get("/wsgi")1170 assert b"Not Found" in rv.data1171 assert rv.status_code == 404

Merge pull request #3111 from pgjones/masterDavid Lordbefore adoption855d59b

line 1172why, one step back
1172

Merge pull request #3229 from lordmauve/style-fixDavid Lordbefore adoption240e398

line 1173why, one step back
1173 rv = client.get("/dict")

Merge pull request #3111 from pgjones/masterDavid Lordbefore adoption855d59b

lines 1174–1175why, one step back
1174 assert rv.json == {"foo": "bar"}
1175 assert rv.status_code == 201

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

lines 1176–1177why, one step back
1176
1177

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1179–1182why, one step back
1179 app = flask.Flask(__name__)
1180 app.testing = True11811182 @app.route("/none")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1184–1186why, one step back
1184 pass
11851186 @app.route("/small_tuple")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1188–1190why, one step back
1188 return ("Hello",)
11891190 @app.route("/large_tuple")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

lines 1195–1196why, one step back
1195 def from_bad_type():
1196 return True

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

lines 1199–1200why, one step back
1199 def from_bad_wsgi():
1200 return lambda: None

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

lines 1201–1205why, one step back
1201
1202 c = app.test_client()12031204 with pytest.raises(TypeError) as e:1205 c.get("/none")

Merge branch '1.0.x'David Lordbefore adoptionb05a685

line 1206why, one step back
1206 assert "returned None" in str(e.value)

Merge pull request #3498 from raymond-devries/3445-traceback-for-noneDavid Lordbefore adoptiona3e4395

line 1207why, one step back
1207 assert "from_none" in str(e.value)

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

lines 1208–1210why, one step back
1208
1209 with pytest.raises(TypeError) as e:1210 c.get("/small_tuple")

Merge branch '1.0.x'David Lordbefore adoptionb05a685

line 1211why, one step back
1211 assert "tuple must have the form" in str(e.value)

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

lines 1212–1216why, one step back
1212
1213 pytest.raises(TypeError, c.get, "/large_tuple")12141215 with pytest.raises(TypeError) as e:1216 c.get("/bad_type")

Merge branch '1.0.x'David Lordbefore adoptionb05a685

line 1217why, one step back
1217 assert "it was a bool" in str(e.value)

Merge pull request #3235 from johnzeringue/better-return-type-errorDavid Lordbefore adoption52f9aa7

line 1218why, one step back
1218

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

lines 1219–1221why, one step back
1219 pytest.raises(TypeError, c.get, "/bad_wsgi")
12201221

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1224–1238why, one step back
1224 assert rv.status_code == 200
1225 assert rv.data == b""1226 assert rv.mimetype == "text/html"12271228 rv = flask.make_response("Awesome")1229 assert rv.status_code == 2001230 assert rv.data == b"Awesome"1231 assert rv.mimetype == "text/html"12321233 rv = flask.make_response("W00t", 404)1234 assert rv.status_code == 4041235 assert rv.data == b"W00t"1236 assert rv.mimetype == "text/html"12371238

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1243–1259why, one step back
1243 assert rv.mimetype == "application/json"
12441245 rv = flask.make_response(flask.Response(""), 400)1246 assert rv.status_code == 4001247 assert rv.data == b""1248 assert rv.mimetype == "text/html"12491250 rv = flask.make_response(1251 flask.Response("", headers={"Content-Type": "text/html"}),1252 400,1253 [("X-Foo", "bar")],1254 )1255 assert rv.status_code == 4001256 assert rv.headers["Content-Type"] == "text/html"1257 assert rv.headers["X-Foo"] == "bar"12581259

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1267–1268why, one step back
1267
1268

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

line 1272why, one step back
1272 pretty_response = (

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1274–1276why, one step back
1274 )
12751276 rv = flask.make_response(flask.jsonify(compressed_msg), 200)

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1278–1279why, one step back
1278
1279

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1281–1285why, one step back
1281 app.config.update({"JSONIFY_MIMETYPE": "application/vnd.api+json"})
1282 msg = {"msg": {"submsg": "W00t"}}1283 rv = flask.make_response(flask.jsonify(msg), 200)1284 assert rv.mimetype == "application/vnd.api+json"1285

Merge pull request #3195 from eruvanos/json_support_dataclassDavid Lordbefore adoptionb0185a6

lines 1286–1289why, one step back
1286
1287@pytest.mark.skipif(sys.version_info < (3, 7), reason="requires Python >= 3.7")1288def test_json_dump_dataclass(app, req_ctx):1289 from dataclasses import make_dataclass

Merge pull request #3229 from lordmauve/style-fixDavid Lordbefore adoption240e398

line 1290why, one step back
1290

Merge pull request #3195 from eruvanos/json_support_dataclassDavid Lordbefore adoptionb0185a6

lines 1291–1294why, one step back
1291 Data = make_dataclass("Data", [("name", str)])
1292 value = flask.json.dumps(Data("Flask"), app=app)1293 value = flask.json.loads(value, app=app)1294 assert value == {"name": "Flask"}

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

line 1295why, one step back
1295

Merge pull request #3229 from lordmauve/style-fixDavid Lordbefore adoption240e398

line 1296why, one step back
1296

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1298–1302why, one step back
1298 with pytest.raises(TypeError) as e:
1299 flask.jsonify("fake args", kwargs="fake")1300 assert "behavior undefined" in str(e.value)13011302

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1306–1314why, one step back
1306 pass
13071308 assert flask.url_for("hello", name="test x") == "/hello/test%20x"1309 assert (1310 flask.url_for("hello", name="test x", _external=True)1311 == "http://localhost/hello/test%20x"1312 )13131314

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1317–1319why, one step back
1317 with app.test_request_context():
1318 pytest.raises(BuildError, flask.url_for, "spam")1319

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

line 1321why, one step back
1321 try:

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

lines 1324–1325why, one step back
1324 except BuildError as err:
1325 error = err

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

line 1328why, one step back
1328 except RuntimeError:

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1334–1335why, one step back
1334 return "/test_handler/"
1335

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1337–1340why, one step back
1337 with app.test_request_context():
1338 assert flask.url_for("spam") == "/test_handler/"13391340

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

lines 1341–1344why, one step back
1341def test_build_error_handler_reraise(app):
1342 # Test a custom handler which reraises the BuildError1343 def handler_raises_build_error(error, endpoint, values):1344 raise error

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

line 1345why, one step back
1345

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1347–1351why, one step back
1347
1348 with app.test_request_context():1349 pytest.raises(BuildError, flask.url_for, "not.existing")13501351

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1356–1366why, one step back
1356 "_external": False,
1357 "_anchor": None,1358 "_method": None,1359 "_scheme": None,1360 }1361 return "handled"13621363 with app.test_request_context():1364 flask.url_for("/")13651366

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1368–1375why, one step back
1368 rv = client.get("/static/index.html")
1369 assert rv.status_code == 2001370 assert rv.data.strip() == b"<h1>Hello World!</h1>"1371 with app.test_request_context():1372 assert flask.url_for("static", filename="index.html") == "/static/index.html"1373 rv.close()13741375

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1377–1386why, one step back
1377 app = flask.Flask(__name__, static_url_path="/foo")
1378 app.testing = True1379 rv = app.test_client().get("/foo/index.html")1380 assert rv.status_code == 2001381 rv.close()13821383 with app.test_request_context():1384 assert flask.url_for("static", filename="index.html") == "/foo/index.html"13851386

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

lines 1387–1397why, one step back
1387def test_static_url_path_with_ending_slash():
1388 app = flask.Flask(__name__, static_url_path="/foo/")1389 app.testing = True1390 rv = app.test_client().get("/foo/index.html")1391 assert rv.status_code == 2001392 rv.close()13931394 with app.test_request_context():1395 assert flask.url_for("static", filename="index.html") == "/foo/index.html"13961397

Merge pull request #3124 from elbeardmorez/fix_static_url_pathDavid Lordbefore adoption754b729

line 1398why, one step back
1398def test_static_url_empty_path(app):

Merge pull request #3229 from lordmauve/style-fixDavid Lordbefore adoption240e398

lines 1399–1400why, one step back
1399 app = flask.Flask(__name__, static_folder="", static_url_path="")
1400 rv = app.test_client().open("/static/index.html", method="GET")

Merge pull request #3124 from elbeardmorez/fix_static_url_pathDavid Lordbefore adoption754b729

lines 1401–1405why, one step back
1401 assert rv.status_code == 200
1402 rv.close()140314041405def test_static_url_empty_path_default(app):

Merge pull request #3229 from lordmauve/style-fixDavid Lordbefore adoption240e398

lines 1406–1407why, one step back
1406 app = flask.Flask(__name__, static_folder="")
1407 rv = app.test_client().open("/static/index.html", method="GET")

Merge pull request #3124 from elbeardmorez/fix_static_url_pathDavid Lordbefore adoption754b729

lines 1408–1411why, one step back
1408 assert rv.status_code == 200
1409 rv.close()14101411

Merge pull request #3579 from jab/pathlib-for-static_folderJoshua Bronsonbefore adoptioncf5b1d0

lines 1412–1421why, one step back
1412@pytest.mark.skipif(sys.version_info < (3, 6), reason="requires Python >= 3.6")
1413def test_static_folder_with_pathlib_path(app):1414 from pathlib import Path14151416 app = flask.Flask(__name__, static_folder=Path("static"))1417 rv = app.test_client().open("/static/index.html", method="GET")1418 assert rv.status_code == 2001419 rv.close()14201421

Merge remote-tracking branch 'origin/1.1.x'David Lordbefore adoption64ba434

lines 1422–1432why, one step back
1422def test_static_folder_with_ending_slash():
1423 app = flask.Flask(__name__, static_folder="static/")14241425 @app.route("/<path:path>")1426 def catch_all(path):1427 return path14281429 rv = app.test_client().get("/catch/all")1430 assert rv.data == b"catch/all"14311432

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1434–1441why, one step back
1434 app = flask.Flask(__name__, host_matching=True, static_host="example.com")
1435 c = app.test_client()1436 rv = c.get("http://example.com/static/index.html")1437 assert rv.status_code == 2001438 rv.close()1439 with app.test_request_context():1440 rv = flask.url_for("static", filename="index.html", _external=True)1441 assert rv == "http://example.com/static/index.html"

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86

lines 1445–1446why, one step back
1445 # Providing host_matching=True with static_folder
1446 # but without static_host should error.

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

line 1448why, one step back
1448 flask.Flask(__name__, host_matching=True)

Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86

lines 1449–1450why, one step back
1449 # Providing host_matching=True without static_host
1450 # but with static_folder=None should not error.

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

line 1451why, one step back
1451 flask.Flask(__name__, host_matching=True, static_folder=None)

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

lines 1452–1453why, one step back
1452
1453

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1457–1458why, one step back
1457
1458

Merge branch '1.0.x'David Lordbefore adoption29111a3

line 1459why, one step back
1459def test_server_name_subdomain():

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

lines 1460–1464why, one step back
1460 app = flask.Flask(__name__, subdomain_matching=True)
1461 client = app.test_client()14621463 @app.route("/")1464 def index():

Merge branch '1.0.x'David Lordbefore adoption29111a3

line 1465why, one step back
1465 return "default"

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

lines 1466–1467why, one step back
1466
1467 @app.route("/", subdomain="foo")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

Merge branch '1.0.x'David Lordbefore adoption29111a3

line 1469why, one step back
1469 return "subdomain"

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

line 1470why, one step back
1470

Merge branch '1.0.x'David Lordbefore adoption29111a3

line 1471why, one step back
1471 app.config["SERVER_NAME"] = "dev.local:5000"

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

line 1472why, one step back
1472 rv = client.get("/")

Merge branch '1.0.x'David Lordbefore adoption29111a3

line 1473why, one step back
1473 assert rv.data == b"default"

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

line 1474why, one step back
1474

Merge branch '1.0.x'David Lordbefore adoption29111a3

lines 1475–1476why, one step back
1475 rv = client.get("/", "http://dev.local:5000")
1476 assert rv.data == b"default"

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

line 1477why, one step back
1477

Merge branch '1.0.x'David Lordbefore adoption29111a3

lines 1478–1479why, one step back
1478 rv = client.get("/", "https://dev.local:5000")
1479 assert rv.data == b"default"

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

line 1480why, one step back
1480

Merge branch '1.0.x'David Lordbefore adoption29111a3

lines 1481–1482why, one step back
1481 app.config["SERVER_NAME"] = "dev.local:443"
1482 rv = client.get("/", "https://dev.local")

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

line 1483why, one step back
1483

Merge branch '1.0.x'David Lordbefore adoption29111a3

lines 1484–1486why, one step back
1484 # Werkzeug 1.0 fixes matching https scheme with 443 port
1485 if rv.status_code != 404:1486 assert rv.data == b"default"

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

line 1487why, one step back
1487

Merge branch '1.0.x'David Lordbefore adoption29111a3

lines 1488–1493why, one step back
1488 app.config["SERVER_NAME"] = "dev.local"
1489 rv = client.get("/", "https://dev.local")1490 assert rv.data == b"default"14911492 # suppress Werkzeug 1.0 warning about name mismatch1493 with pytest.warns(None):

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

lines 1494–1496why, one step back
1494 rv = client.get("/", "http://foo.localhost")
1495 assert rv.status_code == 4041496

Merge branch '1.0.x'David Lordbefore adoption29111a3

lines 1497–1498why, one step back
1497 rv = client.get("/", "http://foo.dev.local")
1498 assert rv.data == b"subdomain"

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

lines 1499–1500why, one step back
1499
1500

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1503–1506why, one step back
1503 @app.route("/")
1504 def index():1505 1 // 01506

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

lines 1507–1509why, one step back
1507 if config_key is not None:
1508 app.config[config_key] = True1509 with pytest.raises(Exception):

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

lines 1510–1513why, one step back
1510 client.get("/")
1511 else:1512 assert client.get("/").status_code == 5001513

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

lines 1519–1521why, one step back
1519 t = Thread(target=apprunner, args=(config_key,))
1520 t.start()1521 t.join()

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

lines 1522–1538why, one step back
1522
15231524@pytest.mark.parametrize("debug", [True, False])1525@pytest.mark.parametrize("use_debugger", [True, False])1526@pytest.mark.parametrize("use_reloader", [True, False])1527@pytest.mark.parametrize("propagate_exceptions", [None, True, False])1528def test_werkzeug_passthrough_errors(1529 monkeypatch, debug, use_debugger, use_reloader, propagate_exceptions, app1530):1531 rv = {}15321533 # Mocks werkzeug.serving.run_simple method1534 def run_simple_mock(*args, **kwargs):1535 rv["passthrough_errors"] = kwargs.get("passthrough_errors")15361537 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)1538 app.config["PROPAGATE_EXCEPTIONS"] = propagate_exceptions

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1540–1541why, one step back
1540
1541

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1543–1545why, one step back
1543 app.config["MAX_CONTENT_LENGTH"] = 64
15441545 @app.before_request

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

line 1547why, one step back
1547 flask.request.form["myfile"]

Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86

line 1548why, one step back
1548 AssertionError()

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

lines 1549–1550why, one step back
1549
1550 @app.route("/accept", methods=["POST"])

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

line 1552why, one step back
1552 flask.request.form["myfile"]

Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86

line 1553why, one step back
1553 AssertionError()

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

line 1554why, one step back
1554

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1557–1562why, one step back
1557 return "42"
15581559 rv = client.post("/accept", data={"myfile": "foo" * 100})1560 assert rv.data == b"42"15611562

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

lines 1563–1565why, one step back
1563def test_url_processors(app, client):
1564 @app.url_defaults1565 def add_language_code(endpoint, values):

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

lines 1566–1570why, one step back
1566 if flask.g.lang_code is not None and app.url_map.is_endpoint_expecting(
1567 endpoint, "lang_code"1568 ):1569 values.setdefault("lang_code", flask.g.lang_code)1570

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1573–1579why, one step back
1573 flask.g.lang_code = values.pop("lang_code", None)
15741575 @app.route("/<lang_code>/")1576 def index():1577 return flask.url_for("about")15781579 @app.route("/<lang_code>/about")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1581–1583why, one step back
1581 return flask.url_for("something_else")
15821583 @app.route("/foo")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1585–1591why, one step back
1585 return flask.url_for("about", lang_code="en")
15861587 assert client.get("/de/").data == b"/de/about"1588 assert client.get("/de/about").data == b"/foo"1589 assert client.get("/foo").data == b"/en/about"15901591

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1597–1599why, one step back
1597 values["page"] = "login"
15981599 @bp.route("/<page>")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1601–1602why, one step back
1601 pass
1602

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

line 1604why, one step back
1604

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1609–1612why, one step back
1609
1610 with app.test_request_context("/somepage"):1611 url = flask.url_for("foo.bar.baz.view")1612 expected = "/login"

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1614–1615why, one step back
1614
1615

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374

line 1617why, one step back
1617 @app.route("/киртест")

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

lines 1618–1620why, one step back
1618 def index():
1619 return "Hello World!"1620

Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374

line 1621why, one step back
1621 rv = client.get("/киртест")

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

lines 1622–1624why, one step back
1622 assert rv.data == b"Hello World!"
16231624

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1626–1631why, one step back
1626 app.debug = True
16271628 @app.route("/")1629 def index():1630 return "Awesome"1631

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1638–1639why, one step back
1638 return "Meh"
1639

Merge branch '1.0.x'David Lordbefore adoptionb05a685

line 1640why, one step back
1640 assert "A setup function was called" in str(e.value)

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

lines 1641–1644why, one step back
1641
1642 app.debug = False16431644 @app.route("/foo")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1646–1651why, one step back
1646 return "Meh"
16471648 assert client.get("/foo").data == b"Meh"1649 assert app.got_first_request16501651

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1653–1665why, one step back
1653 got = []
16541655 @app.before_first_request1656 def foo():1657 got.append(42)16581659 client.get("/")1660 assert got == [42]1661 client.get("/")1662 assert got == [42]1663 assert app.got_first_request16641665

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1667–1670why, one step back
1667 got = []
16681669 @app.before_first_request1670 def foo():

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1672–1673why, one step back
1672 got.append(42)
1673

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

line 1677why, one step back
1677

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

lines 1678–1681why, one step back
1678 t = Thread(target=get_and_assert)
1679 t.start()1680 get_and_assert()1681 t.join()

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

lines 1682–1684why, one step back
1682 assert app.got_first_request
16831684

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1686–1692why, one step back
1686 app.debug = True
16871688 @app.route("/foo/", methods=["GET", "POST"])1689 def foo():1690 return "success"16911692 with client:

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

line 1694why, one step back
1694 client.post("/foo", data={})

Merge branch '1.0.x'David Lordbefore adoptionb05a685

line 1695why, one step back
1695 assert "http://localhost/foo/" in str(e.value)

Merge pull request #3453 from noviluni/remove_redundant_parenthesesDavid Lordbefore adoption986871b

line 1696why, one step back
1696 assert "Make sure to directly send your POST-request to this URL" in str(

Merge branch '1.0.x'David Lordbefore adoptionb05a685

lines 1697–1698why, one step back
1697 e.value
1698 )

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

lines 1699–1708why, one step back
1699
1700 rv = client.get("/foo", data={}, follow_redirects=True)1701 assert rv.data == b"success"17021703 app.debug = False1704 with client:1705 rv = client.post("/foo", data={}, follow_redirects=True)1706 assert rv.data == b"success"17071708

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1710–1716why, one step back
1710 app.debug = True
17111712 @app.route("/foo/")1713 def foo():1714 return flask.request.endpoint17151716 @app.route("/bar/", endpoint="bar")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1718–1720why, one step back
1718 return flask.request.endpoint
17191720 @app.route("/bar/123", endpoint="123")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1722–1733why, one step back
1722 return flask.request.endpoint
17231724 with app.test_request_context():1725 assert flask.url_for("foo") == "/foo/"1726 assert flask.url_for("bar") == "/bar/"1727 assert flask.url_for("123") == "/bar/123"17281729 assert client.get("/foo/").data == b"foo"1730 assert client.get("/bar/").data == b"bar"1731 assert client.get("/bar/123").data == b"123"17321733

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1735–1740why, one step back
1735 app.debug = True
17361737 @app.route("/fail")1738 def fail_func():1739 1 // 01740

Merge pull request #3241 from jon-stumpf/jss-updatesDavid Lordbefore adoption48d0e86

line 1741why, one step back
1741 for _x in range(3):

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

line 1742why, one step back
1742 with pytest.raises(ZeroDivisionError):

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

lines 1743–1744why, one step back
1743 client.get("/fail")
1744

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

lines 1745–1750why, one step back
1745 assert flask._request_ctx_stack.top is not None
1746 assert flask._app_ctx_stack.top is not None1747 # implicit appctx disappears too1748 flask._request_ctx_stack.top.pop()1749 assert flask._request_ctx_stack.top is None1750 assert flask._app_ctx_stack.top is None

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

lines 1751–1752why, one step back
1751
1752

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1756–1761why, one step back
1756
1757 @app.route("/fail")1758 def fail_func():1759 1 // 017601761 @app.route("/success")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1763–1765why, one step back
1763 return "Okay"
17641765 @app.teardown_request

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

line 1768why, one step back
1768

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

line 1773why, one step back
1773

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

line 1778why, one step back
1778

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1783–1784why, one step back
1783
1784

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1791–1792why, one step back
1791
1792

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

lines 1793–1795why, one step back
1793def test_g_iteration_protocol(app_ctx):
1794 flask.g.foo = 231795 flask.g.bar = 42

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

lines 1796–1800why, one step back
1796 assert "foo" in flask.g
1797 assert "foos" not in flask.g1798 assert sorted(flask.g) == ["bar", "foo"]17991800

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1802–1806why, one step back
1802 app = flask.Flask(__name__, subdomain_matching=True)
1803 app.config["SERVER_NAME"] = "localhost.localdomain"1804 client = app.test_client()18051806 @app.route("/")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1808–1810why, one step back
1808 return "normal index"
18091810 @app.route("/", subdomain="test")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1812–1820why, one step back
1812 return "test index"
18131814 rv = client.get("/", "http://localhost.localdomain/")1815 assert rv.data == b"normal index"18161817 rv = client.get("/", "http://test.localhost.localdomain/")1818 assert rv.data == b"test index"18191820

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1822–1827why, one step back
1822 app = flask.Flask(__name__, subdomain_matching=True)
1823 client = app.test_client()1824 app.config["SERVER_NAME"] = "localhost.localdomain"18251826 @app.route("/", subdomain="<user>")1827 def index(user):

Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374

line 1828why, one step back
1828 return f"index for {user}"

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

lines 1829–1833why, one step back
1829
1830 rv = client.get("/", "http://mitsuhiko.localhost.localdomain/")1831 assert rv.data == b"index for mitsuhiko"18321833

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1835–1840why, one step back
1835 app = flask.Flask(__name__, subdomain_matching=True)
1836 app.config["SERVER_NAME"] = "localhost.localdomain:3000"1837 client = app.test_client()18381839 @app.route("/", subdomain="<user>")1840 def index(user):

Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374

line 1841why, one step back
1841 return f"index for {user}"

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

lines 1842–1847why, one step back
1842
1843 rv = client.get("/", "http://mitsuhiko.localhost.localdomain:3000/")1844 assert rv.data == b"index for mitsuhiko"184518461847@pytest.mark.parametrize("matching", (False, True))

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1850–1856why, one step back
1850 app.config["SERVER_NAME"] = "localhost.localdomain:3000"
1851 client = app.test_client()18521853 @app.route("/")1854 def index():1855 return "", 2041856

Merge branch '1.0.x'David Lordbefore adoption29111a3

lines 1857–1861why, one step back
1857 # suppress Werkzeug 0.15 warning about name mismatch
1858 with pytest.warns(None):1859 # ip address can't match name1860 rv = client.get("/", "http://127.0.0.1:3000/")1861 assert rv.status_code == 404 if matching else 204

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

line 1862why, one step back
1862

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1864–1867why, one step back
1864 rv = client.get("/", "http://www.localhost.localdomain:3000/")
1865 assert rv.status_code == 404 if matching else 20418661867

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1869–1871why, one step back
1869 @app.route("/")
1870 @app.route("/<test>/")1871 def index(test="a"):

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

line 1872why, one step back
1872 return test

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

lines 1873–1879why, one step back
1873
1874 rv = client.open("/")1875 assert rv.data == b"a"1876 rv = client.open("/b/")1877 assert rv.data == b"b"18781879

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

line 1880why, one step back
1880def test_multi_route_class_views(app, client):

Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374

line 1881why, one step back
1881 class View:

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

line 1882why, one step back
1882 def __init__(self, app):

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

lines 1883–1886why, one step back
1883 app.add_url_rule("/", "index", self.index)
1884 app.add_url_rule("/<test>/", "index", self.index)18851886 def index(self, test="a"):

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

line 1887why, one step back
1887 return test

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

line 1888why, one step back
1888

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1890–1895why, one step back
1890 rv = client.open("/")
1891 assert rv.data == b"a"1892 rv = client.open("/b/")1893 assert rv.data == b"b"18941895

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1897–1903why, one step back
1897 rv = {}
18981899 # Mocks werkzeug.serving.run_simple method1900 def run_simple_mock(*args, **kwargs):1901 rv["result"] = "running..."19021903 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1905–1907why, one step back
1905 assert rv["result"] == "running..."
19061907

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1909–1911why, one step back
1909 rv = {}
19101911 # Mocks werkzeug.serving.run_simple method

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374

line 1913why, one step back
1913 rv["result"] = f"running on {hostname}:{port} ..."

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

lines 1914–1916why, one step back
1914
1915 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)1916 hostname, port = "localhost", 8000

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

Merge pull request #3554 from pallets/drop-python2David Lordbefore adoptioncd8a374

line 1918why, one step back
1918 assert rv["result"] == f"running on {hostname}:{port} ..."

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

lines 1919–1921why, one step back
1919
19201921@pytest.mark.parametrize(

Merge pull request #2928 from vorelq/2926-default-port-overrides-zeroDavid Lordbefore adoptiond9fa28b

line 1922why, one step back
1922 "host,port,server_name,expect_host,expect_port",

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

line 1923why, one step back
1923 (

Merge pull request #2928 from vorelq/2926-default-port-overrides-zeroDavid Lordbefore adoptiond9fa28b

lines 1924–1930why, one step back
1924 (None, None, "pocoo.org:8080", "pocoo.org", 8080),
1925 ("localhost", None, "pocoo.org:8080", "localhost", 8080),1926 (None, 80, "pocoo.org:8080", "pocoo.org", 80),1927 ("localhost", 80, "pocoo.org:8080", "localhost", 80),1928 ("localhost", 0, "localhost:8080", "localhost", 0),1929 (None, None, "localhost:8080", "localhost", 8080),1930 (None, None, "localhost:0", "localhost", 0),

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

lines 1931–1932why, one step back
1931 ),
1932)

Merge pull request #3229 from lordmauve/style-fixDavid Lordbefore adoption240e398

lines 1933–1935why, one step back
1933def test_run_from_config(
1934 monkeypatch, host, port, server_name, expect_host, expect_port, app1935):

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

lines 1936–1938why, one step back
1936 def run_simple_mock(hostname, port, *args, **kwargs):
1937 assert hostname == expect_host1938 assert port == expect_port

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

lines 1939–1940why, one step back
1939
1940 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)

Merge pull request #2928 from vorelq/2926-default-port-overrides-zeroDavid Lordbefore adoptiond9fa28b

line 1941why, one step back
1941 app.config["SERVER_NAME"] = server_name

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1943–1944why, one step back
1943
1944

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

lines 1948–1950why, one step back
1948 # outside app context, default to Werkzeug static value,
1949 # which is also the default config1950 response = flask.Response()

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

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

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

line 1953why, one step back
1953

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1957–1961why, one step back
1957
1958 @app.route("/")1959 def index():1960 r = flask.Response("", status=204)1961 r.set_cookie("foo", "bar" * 100)

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

line 1962why, one step back
1962 return r

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

lines 1963–1964why, one step back
1963
1964 client.get("/")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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

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

lines 1967–1971why, one step back
1967 assert "cookie is too large" in str(w.message)
19681969 app.config["MAX_COOKIE_SIZE"] = 019701971 client.get("/")

Add prefix for all commands in documentation (#2877)Grey Libefore adoption21b0aa6

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