Skip to content
Myr

test_basic.py

This file

Path

tests/test_basic.py

1,993 lines · 53.6 KiB · Python

Last changed by

Fix style issues on master using BlackDaniel Popebefore adoptiona5ff3cd

History of this file

Take it

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

Merge pull request #2624 from pallets/metadataDavid Lordbefore adoption4309c7c

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 9–12why, one step back
9 :license: BSD, see LICENSE for more details.
10"""1112import re

Merge pull request #3195 from eruvanos/json_support_dataclassDavid Lordbefore adoptionb0185a6

line 13why, one step back
13import sys

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 14–29why, one step back
14import time
15import uuid16from datetime import datetime17from threading import Thread1819import pytest20import werkzeug.serving21from werkzeug.exceptions import BadRequest, Forbidden, NotFound22from werkzeug.http import parse_date23from werkzeug.routing import BuildError2425import flask26from flask._compat import text_type272829def test_options_work(app, client):

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 46–51why, one step back
46 return "Aha!"
4748 rv = client.open("/", method="OPTIONS")49 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS", "POST", "PUT"]5051

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 75–81why, one step back
75 def index():
76 return flask.request.method7778 def more():79 return flask.request.method8081 app.add_url_rule("/", view_func=index, provide_automatic_options=False)

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 83–93why, one step back
83 "/more",
84 view_func=more,85 methods=["GET", "POST"],86 provide_automatic_options=False,87 )88 assert client.get("/").data == b"GET"8990 rv = client.post("/")91 assert rv.status_code == 40592 assert sorted(rv.allow) == ["GET", "HEAD"]93

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 95–119why, one step back
95 if hasattr(client, "options"):
96 rv = client.options("/")97 else:98 rv = client.open("/", method="OPTIONS")99100 assert rv.status_code == 405101102 rv = client.head("/")103 assert rv.status_code == 200104 assert not rv.data # head truncates105 assert client.post("/more").data == b"POST"106 assert client.get("/more").data == b"GET"107108 rv = client.delete("/more")109 assert rv.status_code == 405110 assert sorted(rv.allow) == ["GET", "HEAD", "POST"]111112 if hasattr(client, "options"):113 rv = client.options("/more")114 else:115 rv = client.open("/more", method="OPTIONS")116117 assert rv.status_code == 405118119

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 121–142why, one step back
121 @app.route("/")
122 def index():123 return flask.request.method124125 @app.route("/more", methods=["GET", "POST"])126 def more():127 return flask.request.method128129 assert client.get("/").data == b"GET"130 rv = client.post("/")131 assert rv.status_code == 405132 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS"]133 rv = client.head("/")134 assert rv.status_code == 200135 assert not rv.data # head truncates136 assert client.post("/more").data == b"POST"137 assert client.get("/more").data == b"GET"138 rv = client.delete("/more")139 assert rv.status_code == 405140 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS", "POST"]141142

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 149–150why, one step back
149
150

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 153–159why, one step back
153
154 def index():155 return flask.request.method156157 def more():158 return flask.request.method159

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 167–182why, one step back
167 app.add_url_rule("/options", "options", options, methods=["options"])
168169 assert client.get("/").data == b"GET"170 rv = client.post("/")171 assert rv.status_code == 405172 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS"]173 rv = client.head("/")174 assert rv.status_code == 200175 assert not rv.data # head truncates176 assert client.post("/more").data == b"POST"177 assert client.get("/more").data == b"GET"178 rv = client.delete("/more")179 assert rv.status_code == 405180 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS", "POST"]181 rv = client.open("/options", method="OPTIONS")182 assert rv.status_code == 200

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 184–185why, one step back
184
185

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 187–205why, one step back
187 from werkzeug.routing import Submount, Rule
188189 app.url_map.add(190 Submount("/foo", [Rule("/bar", endpoint="bar"), Rule("/", endpoint="index")])191 )192193 def bar():194 return "bar"195196 def index():197 return "index"198199 app.view_functions["bar"] = bar200 app.view_functions["index"] = index201202 assert client.get("/foo/").data == b"index"203 assert client.get("/foo/bar").data == b"bar"204205

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 207–224why, one step back
207 from werkzeug.routing import Submount, Rule
208209 app.url_map.add(210 Submount("/foo", [Rule("/bar", endpoint="bar"), Rule("/", endpoint="index")])211 )212213 @app.endpoint("bar")214 def bar():215 return "bar"216217 @app.endpoint("index")218 def index():219 return "index"220221 assert client.get("/foo/").data == b"index"222 assert client.get("/foo/bar").data == b"bar"223224

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 228–231why, one step back
228 assert not flask.session.accessed
229 assert not flask.session.modified230 flask.session["value"] = flask.request.form["value"]231 assert flask.session.accessed

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

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

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

lines 233–241why, one step back
233 return "value set"
234235 @app.route("/get")236 def get():237 assert not flask.session.accessed238 assert not flask.session.modified239 v = flask.session.get("value", "None")240 assert flask.session.accessed241 assert not flask.session.modified

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

line 242why, one step back
242 return v

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 249–260why, one step back
249 app.config.update(SERVER_NAME="example.com")
250251 @app.route("/")252 def index():253 flask.session["testing"] = 42254 return "Hello World"255256 rv = client.get("/", "http://example.com/")257 assert "domain=.example.com" in rv.headers["set-cookie"].lower()258 assert "httponly" in rv.headers["set-cookie"].lower()259260

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 262–273why, one step back
262 app.config.update(SERVER_NAME="example.com:8080")
263264 @app.route("/")265 def index():266 flask.session["testing"] = 42267 return "Hello World"268269 rv = client.get("/", "http://example.com:8080/")270 assert "domain=.example.com" in rv.headers["set-cookie"].lower()271 assert "httponly" in rv.headers["set-cookie"].lower()272273

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 275–287why, one step back
275 app.config.update(SERVER_NAME="example.com:8080", APPLICATION_ROOT="/foo")
276277 @app.route("/")278 def index():279 flask.session["testing"] = 42280 return "Hello World"281282 rv = client.get("/", "http://example.com:8080/foo")283 assert "domain=example.com" in rv.headers["set-cookie"].lower()284 assert "path=/foo" in rv.headers["set-cookie"].lower()285 assert "httponly" in rv.headers["set-cookie"].lower()286287

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

line 293why, one step back
293

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 297–309why, one step back
297
298 app.wsgi_app = PrefixPathMiddleware(app.wsgi_app, "/bar")299 app.config.update(APPLICATION_ROOT="/bar")300301 @app.route("/")302 def index():303 flask.session["testing"] = 42304 return "Hello World"305306 rv = client.get("/", "http://example.com:8080/")307 assert "path=/bar" in rv.headers["set-cookie"].lower()308309

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 317–334why, one step back
317 SESSION_COOKIE_SAMESITE="Lax",
318 SESSION_COOKIE_PATH="/",319 )320321 @app.route("/")322 def index():323 flask.session["testing"] = 42324 return "Hello World"325326 rv = client.get("/", "http://www.example.com:8080/test/")327 cookie = rv.headers["set-cookie"].lower()328 assert "domain=.example.com" in cookie329 assert "path=/" in cookie330 assert "secure" in cookie331 assert "httponly" not in cookie332 assert "samesite" in cookie333334

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

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

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

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

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

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

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

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

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

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

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

lines 347–361why, one step back
347 rv = client.get("/")
348 cookie = rv.headers["set-cookie"].lower()349 assert "samesite" not in cookie350351 app.config.update(SESSION_COOKIE_SAMESITE="Strict")352 rv = client.get("/")353 cookie = rv.headers["set-cookie"].lower()354 assert "samesite=strict" in cookie355356 app.config.update(SESSION_COOKIE_SAMESITE="Lax")357 rv = client.get("/")358 cookie = rv.headers["set-cookie"].lower()359 assert "samesite=lax" in cookie360361

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 374–375why, one step back
374
375

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 377–389why, one step back
377 app.config.update(SERVER_NAME="127.0.0.1:5000")
378379 @app.route("/")380 def index():381 flask.session["testing"] = 42382 return "testing"383384 rv = client.get("/", "http://127.0.0.1:5000/")385 assert "domain=127.0.0.1" in rv.headers["set-cookie"].lower()386 w = recwarn.pop(UserWarning)387 assert "cookie domain is an IP" in str(w.message)388389

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

line 392why, one step back
392

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 395–402why, one step back
395 assert e.value.args and "session is unavailable" in e.value.args[0]
396397 with app.test_request_context():398 assert flask.session.get("missing_key") is None399 expect_exception(flask.session.__setitem__, "foo", 42)400 expect_exception(flask.session.pop, "foo")401402

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 410–413why, one step back
410 return ""
411412 @app.route("/test")413 def test():

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 419–423why, one step back
419 expires = parse_date(match.group())
420 expected = datetime.utcnow() + app.permanent_session_lifetime421 assert expires.year == expected.year422 assert expires.month == expected.month423 assert expires.day == expected.day

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 428why, one step back
428 permanent = False

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 433–434why, one step back
433
434

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 438–448why, one step back
438 flask.session["foo"] = 42
439 return response440441 @app.route("/")442 def dump_session_contents():443 return repr(flask.session.get("foo"))444445 assert client.get("/").data == b"None"446 assert client.get("/").data == b"42"447448

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 468–479why, one step back
468 assert s["t"] == (1, 2, 3)
469 assert type(s["b"]) == bytes470 assert s["b"] == b"\xff"471 assert type(s["m"]) == flask.Markup472 assert s["m"] == flask.Markup("<html>")473 assert s["u"] == the_uuid474 assert s["d"] == now475 assert s["t_tag"] == {" t": "not-a-tuple"}476 assert s["di_t_tag"] == {" t__": "not-a-tuple"}477 assert s["di_tag"] == {" di": "not-a-dict"}478479

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 481–483why, one step back
481 is_permanent = True
482483 @app.route("/bump")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 502–505why, one step back
502 assert rv.data == b"3"
503504 is_permanent = True505 app.config["SESSION_REFRESH_EACH_REQUEST"] = True

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 507–520why, one step back
507
508 is_permanent = True509 app.config["SESSION_REFRESH_EACH_REQUEST"] = False510 run_test(expect_header=False)511512 is_permanent = False513 app.config["SESSION_REFRESH_EACH_REQUEST"] = True514 run_test(expect_header=False)515516 is_permanent = False517 app.config["SESSION_REFRESH_EACH_REQUEST"] = False518 run_test(expect_header=False)519520

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 524–531why, one step back
524 flask.session["test"] = "test"
525 return ""526527 @app.route("/get")528 def get():529 return flask.session.get("test")530531 @app.route("/getitem")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 533–535why, one step back
533 return flask.session["test"]
534535 @app.route("/setdefault")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 555–557why, one step back
555 return ""
556557 def expect(path, header_value="Cookie"):

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

line 559why, one step back
559

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 562–575why, one step back
562 assert len(rv.headers.get_all("Vary")) == 1
563 assert rv.headers["Vary"] == header_value564 else:565 assert "Vary" not in rv.headers566567 expect("/set")568 expect("/get")569 expect("/getitem")570 expect("/setdefault")571 expect("/vary-cookie-header-set")572 expect("/vary-header-set", "Accept-Encoding, Accept-Language, Cookie")573 expect("/no-vary-header", None)574575

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 582–584why, one step back
582 assert list(flask.get_flashed_messages()) == ["Zap", "Zip"]
583584

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 622–628why, one step back
622 messages = flask.get_flashed_messages(
623 category_filter=["message"], with_categories=True624 )625 assert list(messages) == [("message", u"Hello World")]626 return ""627628 @app.route("/test_filters/")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 648–665why, one step back
648
649 client = app.test_client()650 client.get("/")651 client.get("/test_with_categories/")652653 client = app.test_client()654 client.get("/")655 client.get("/test_filter/")656657 client = app.test_client()658 client.get("/")659 client.get("/test_filters/")660661 client = app.test_client()662 client.get("/")663 client.get("/test_filters_without_returning_categories/")664665

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 667–690why, one step back
667 evts = []
668669 @app.before_request670 def before_request():671 evts.append("before")672673 @app.after_request674 def after_request(response):675 response.data += b"|after"676 evts.append("after")677 return response678679 @app.route("/")680 def index():681 assert "before" in evts682 assert "after" not in evts683 return "request"684685 assert "after" not in evts686 rv = client.get("/").data687 assert "after" in evts688 assert rv == b"request|after"689690

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 692–694why, one step back
692 evts = []
693694 @app.before_request

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 716–717why, one step back
716
717

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 724why, one step back
724 return response

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

lines 725–728why, one step back
725
726 return "Test"727728 resp = client.get("/")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 730–732why, one step back
730 assert resp.headers["X-Foo"] == "a header"
731732

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 733why, one step back
733def test_teardown_request_handler(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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 752–768why, one step back
752 called = []
753754 @app.teardown_request755 def teardown_request(exc):756 called.append(True)757 return "Ignored"758759 @app.route("/")760 def root():761 return "Response"762763 rv = client.get("/")764 assert rv.status_code == 200765 assert b"Response" in rv.data766 assert len(called) == 1767768

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 770–773why, one step back
770 called = []
771 app.testing = False772773 @app.teardown_request

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 799–803why, one step back
799 1 // 0
800801 rv = client.get("/")802 assert rv.status_code == 500803 assert b"Internal Server Error" in rv.data

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 805–806why, one step back
805
806

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 808–810why, one step back
808 called = []
809810 @app.before_request

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 821–823why, one step back
821 return response
822823 @app.after_request

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 826–828why, one step back
826 return response
827828 @app.teardown_request

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 843–844why, one step back
843
844

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 846–848why, one step back
846 app.testing = False
847848 @app.errorhandler(404)

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 850–855why, one step back
850 return "not found", 404
851852 @app.errorhandler(500)853 def internal_server_error(e):854 return "internal server error", 500855

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 858–864why, one step back
858 return "forbidden", 403
859860 @app.route("/")861 def index():862 flask.abort(404)863864 @app.route("/error")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 866–868why, one step back
866 1 // 0
867868 @app.route("/forbidden")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 870–878why, one step back
870 flask.abort(403)
871872 rv = client.get("/")873 assert rv.status_code == 404874 assert rv.data == b"not found"875 rv = client.get("/error")876 assert rv.status_code == 500877 assert b"internal server error" == rv.data878 rv = client.get("/forbidden")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 880–882why, one step back
880 assert b"forbidden" == rv.data
881882

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 885–889why, one step back
885 app.register_error_handler(999, lambda e: ("999", 999))
886887 assert "Use a subclass" in exc_info.value.args[0]888889

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 891–901why, one step back
891 app.testing = False
892893 @app.errorhandler(500)894 def internal_server_error(e):895 return "internal server error", 500896897 @app.route("/")898 def broken_func():899 1 // 0900901 @app.after_request

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 904why, one step back
904 return resp

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 912–915why, one step back
912 app.testing = False
913914 @app.route("/")915 def broken_func():

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

line 917why, one step back
917

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 924–925why, one step back
924
925

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 929–931why, one step back
929 flask.g.something = "value"
930931 @app.errorhandler(404)

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 934–939why, one step back
934
935 rv = client.get("/")936 assert rv.status_code == 404937 assert rv.data == b"value"938939

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 947–950why, one step back
947 return "42"
948949 @app.route("/")950 def index():

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 952–955why, one step back
952
953 assert client.get("/").data == b"42"954955

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 969–971why, one step back
969 return "apple"
970971 @app.route("/1")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1004–1006why, one step back
1004 return "Exception"
10051006 @app.route("/E1")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1013–1020why, one step back
1013
1014 rv = client.get("/E1")1015 assert rv.data == b"Exception"10161017 rv = client.get("/E3")1018 assert rv.data == b"E2"10191020

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

Merge branch '1.0-maintenance'David Lordbefore adoption1fa9185

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

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

lines 1029–1036why, one step back
1029
1030 rv = client.get("/key")1031 assert rv.status_code == 4001032 assert b"missing_key" not in rv.data1033 rv = client.get("/abort")1034 assert rv.status_code == 40010351036 app.debug = True

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

Merge branch '1.0-maintenance'David Lordbefore adoption1fa9185

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

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

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

Merge branch '1.0-maintenance'David Lordbefore adoption1fa9185

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

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

lines 1049–1051why, one step back
1049 client.get("/abort")
10501051

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1060–1062why, one step back
1060 client.get("/fail")
10611062

Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469

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

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

lines 1064–1086why, one step back
1064 app.testing = False
10651066 @app.before_request1067 def before_request():1068 if trigger == "before":1069 1 // 010701071 @app.after_request1072 def after_request(response):1073 if trigger == "after":1074 1 // 01075 return response10761077 @app.route("/")1078 def index():1079 return "Foo"10801081 @app.errorhandler(500)1082 def internal_server_error(e):1083 return "Hello Server Error", 50010841085 for trigger in "before", "after":1086 rv = client.get("/")

Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469

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

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

lines 1088–1090why, one step back
1088 assert rv.data == b"Hello Server Error"
10891090

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

line 1103why, one step back
1103 with client:

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1108–1109why, one step back
1108
1109

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1133–1135why, one step back
1133 return "Hi, status!", 400
11341135 @app.route("/response_headers")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1144–1146why, one step back
1144 return app.response_class("Hello world", 400), 500
11451146 @app.route("/wsgi")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

line 1149why, one step back
1149

Fix style issues on master using BlackDaniel Popebefore adoptiona5ff3cd

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

Merge pull request #3111 from pgjones/masterDavid Lordbefore adoption855d59b

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

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

line 1153why, one step back
1153

Fix style issues on master using BlackDaniel Popebefore adoptiona5ff3cd

lines 1154–1155why, one step back
1154 assert client.get("/text").data == u"Hällo Wörld".encode("utf-8")
1155 assert client.get("/bytes").data == u"Hällo Wörld".encode("utf-8")

Merge pull request #3111 from pgjones/masterDavid Lordbefore adoption855d59b

line 1156why, one step back
1156

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

lines 1157–1186why, one step back
1157 rv = client.get("/full_tuple")
1158 assert rv.data == b"Meh"1159 assert rv.headers["X-Foo"] == "Testing"1160 assert rv.status_code == 4001161 assert rv.mimetype == "text/plain"11621163 rv = client.get("/text_headers")1164 assert rv.data == b"Hello"1165 assert rv.headers["X-Foo"] == "Test"1166 assert rv.status_code == 2001167 assert rv.mimetype == "text/plain"11681169 rv = client.get("/text_status")1170 assert rv.data == b"Hi, status!"1171 assert rv.status_code == 4001172 assert rv.mimetype == "text/html"11731174 rv = client.get("/response_headers")1175 assert rv.data == b"Hello world"1176 assert rv.headers.getlist("X-Foo") == ["Baz", "Bar"]1177 assert rv.headers["X-Bar"] == "Foo"1178 assert rv.status_code == 40411791180 rv = client.get("/response_status")1181 assert rv.data == b"Hello world"1182 assert rv.status_code == 50011831184 rv = client.get("/wsgi")1185 assert b"Not Found" in rv.data1186 assert rv.status_code == 404

Merge pull request #3111 from pgjones/masterDavid Lordbefore adoption855d59b

line 1187why, one step back
1187

Fix style issues on master using BlackDaniel Popebefore adoptiona5ff3cd

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

Merge pull request #3111 from pgjones/masterDavid Lordbefore adoption855d59b

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

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

lines 1191–1192why, one step back
1191
1192

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1194–1197why, one step back
1194 app = flask.Flask(__name__)
1195 app.testing = True11961197 @app.route("/none")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1199–1201why, one step back
1199 pass
12001201 @app.route("/small_tuple")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1203–1205why, one step back
1203 return ("Hello",)
12041205 @app.route("/large_tuple")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1210–1211why, one step back
1210 def from_bad_type():
1211 return True

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1214–1215why, one step back
1214 def from_bad_wsgi():
1215 return lambda: None

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

lines 1216–1235why, one step back
1216
1217 c = app.test_client()12181219 with pytest.raises(TypeError) as e:1220 c.get("/none")1221 assert "returned None" in str(e)12221223 with pytest.raises(TypeError) as e:1224 c.get("/small_tuple")1225 assert "tuple must have the form" in str(e)12261227 pytest.raises(TypeError, c.get, "/large_tuple")12281229 with pytest.raises(TypeError) as e:1230 c.get("/bad_type")1231 assert "it was a bool" in str(e)12321233 pytest.raises(TypeError, c.get, "/bad_wsgi")12341235

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1238–1252why, one step back
1238 assert rv.status_code == 200
1239 assert rv.data == b""1240 assert rv.mimetype == "text/html"12411242 rv = flask.make_response("Awesome")1243 assert rv.status_code == 2001244 assert rv.data == b"Awesome"1245 assert rv.mimetype == "text/html"12461247 rv = flask.make_response("W00t", 404)1248 assert rv.status_code == 4041249 assert rv.data == b"W00t"1250 assert rv.mimetype == "text/html"12511252

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1257–1273why, one step back
1257 assert rv.mimetype == "application/json"
12581259 rv = flask.make_response(flask.Response(""), 400)1260 assert rv.status_code == 4001261 assert rv.data == b""1262 assert rv.mimetype == "text/html"12631264 rv = flask.make_response(1265 flask.Response("", headers={"Content-Type": "text/html"}),1266 400,1267 [("X-Foo", "bar")],1268 )1269 assert rv.status_code == 4001270 assert rv.headers["Content-Type"] == "text/html"1271 assert rv.headers["X-Foo"] == "bar"12721273

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1281–1282why, one step back
1281
1282

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

line 1286why, one step back
1286 pretty_response = (

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1288–1290why, one step back
1288 )
12891290 rv = flask.make_response(flask.jsonify(compressed_msg), 200)

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1292–1293why, one step back
1292
1293

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1295–1299why, one step back
1295 app.config.update({"JSONIFY_MIMETYPE": "application/vnd.api+json"})
1296 msg = {"msg": {"submsg": "W00t"}}1297 rv = flask.make_response(flask.jsonify(msg), 200)1298 assert rv.mimetype == "application/vnd.api+json"1299

Merge pull request #3195 from eruvanos/json_support_dataclassDavid Lordbefore adoptionb0185a6

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

Fix style issues on master using BlackDaniel Popebefore adoptiona5ff3cd

line 1304why, one step back
1304

Merge pull request #3195 from eruvanos/json_support_dataclassDavid Lordbefore adoptionb0185a6

lines 1305–1308why, one step back
1305 Data = make_dataclass("Data", [("name", str)])
1306 value = flask.json.dumps(Data("Flask"), app=app)1307 value = flask.json.loads(value, app=app)1308 assert value == {"name": "Flask"}

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

line 1309why, one step back
1309

Fix style issues on master using BlackDaniel Popebefore adoptiona5ff3cd

line 1310why, one step back
1310

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1312–1316why, one step back
1312 with pytest.raises(TypeError) as e:
1313 flask.jsonify("fake args", kwargs="fake")1314 assert "behavior undefined" in str(e.value)13151316

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1320–1328why, one step back
1320 pass
13211322 assert flask.url_for("hello", name="test x") == "/hello/test%20x"1323 assert (1324 flask.url_for("hello", name="test x", _external=True)1325 == "http://localhost/hello/test%20x"1326 )13271328

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1331–1333why, one step back
1331 with app.test_request_context():
1332 pytest.raises(BuildError, flask.url_for, "spam")1333

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

line 1335why, one step back
1335 try:

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1338–1339why, one step back
1338 except BuildError as err:
1339 error = err

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1342why, one step back
1342 except RuntimeError:

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1348–1349why, one step back
1348 return "/test_handler/"
1349

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1351–1354why, one step back
1351 with app.test_request_context():
1352 assert flask.url_for("spam") == "/test_handler/"13531354

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1355–1358why, one step back
1355def test_build_error_handler_reraise(app):
1356 # Test a custom handler which reraises the BuildError1357 def handler_raises_build_error(error, endpoint, values):1358 raise error

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

line 1359why, one step back
1359

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1361–1365why, one step back
1361
1362 with app.test_request_context():1363 pytest.raises(BuildError, flask.url_for, "not.existing")13641365

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1370–1380why, one step back
1370 "_external": False,
1371 "_anchor": None,1372 "_method": None,1373 "_scheme": None,1374 }1375 return "handled"13761377 with app.test_request_context():1378 flask.url_for("/")13791380

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

line 1383why, one step back
1383

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1386–1387why, one step back
1386 return value.split(",")
1387

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1396–1400why, one step back
1396 return "|".join(args)
13971398 assert client.get("/1,2,3").data == b"1|2|3"13991400

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1402–1409why, one step back
1402 rv = client.get("/static/index.html")
1403 assert rv.status_code == 2001404 assert rv.data.strip() == b"<h1>Hello World!</h1>"1405 with app.test_request_context():1406 assert flask.url_for("static", filename="index.html") == "/static/index.html"1407 rv.close()14081409

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1411–1420why, one step back
1411 app = flask.Flask(__name__, static_url_path="/foo")
1412 app.testing = True1413 rv = app.test_client().get("/foo/index.html")1414 assert rv.status_code == 2001415 rv.close()14161417 with app.test_request_context():1418 assert flask.url_for("static", filename="index.html") == "/foo/index.html"14191420

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

lines 1421–1431why, one step back
1421def test_static_url_path_with_ending_slash():
1422 app = flask.Flask(__name__, static_url_path="/foo/")1423 app.testing = True1424 rv = app.test_client().get("/foo/index.html")1425 assert rv.status_code == 2001426 rv.close()14271428 with app.test_request_context():1429 assert flask.url_for("static", filename="index.html") == "/foo/index.html"14301431

Merge pull request #3124 from elbeardmorez/fix_static_url_pathDavid Lordbefore adoption754b729

line 1432why, one step back
1432def test_static_url_empty_path(app):

Fix style issues on master using BlackDaniel Popebefore adoptiona5ff3cd

lines 1433–1434why, one step back
1433 app = flask.Flask(__name__, static_folder="", static_url_path="")
1434 rv = app.test_client().open("/static/index.html", method="GET")

Merge pull request #3124 from elbeardmorez/fix_static_url_pathDavid Lordbefore adoption754b729

lines 1435–1439why, one step back
1435 assert rv.status_code == 200
1436 rv.close()143714381439def test_static_url_empty_path_default(app):

Fix style issues on master using BlackDaniel Popebefore adoptiona5ff3cd

lines 1440–1441why, one step back
1440 app = flask.Flask(__name__, static_folder="")
1441 rv = app.test_client().open("/static/index.html", method="GET")

Merge pull request #3124 from elbeardmorez/fix_static_url_pathDavid Lordbefore adoption754b729

lines 1442–1445why, one step back
1442 assert rv.status_code == 200
1443 rv.close()14441445

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1447–1454why, one step back
1447 app = flask.Flask(__name__, host_matching=True, static_host="example.com")
1448 c = app.test_client()1449 rv = c.get("http://example.com/static/index.html")1450 assert rv.status_code == 2001451 rv.close()1452 with app.test_request_context():1453 rv = flask.url_for("static", filename="index.html", _external=True)1454 assert rv == "http://example.com/static/index.html"

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1463–1464why, one step back
1463
1464

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1468–1469why, one step back
1468
1469

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

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

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

lines 1471–1479why, one step back
1471 app = flask.Flask(__name__, subdomain_matching=True)
1472 app.config.update(SERVER_NAME="localhost.localdomain:5000")1473 client = app.test_client()14741475 @app.route("/")1476 def index():1477 return "Foo"14781479 @app.route("/", subdomain="foo")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1481–1504why, one step back
1481 return "Foo SubDomain"
14821483 rv = client.get("/")1484 assert rv.data == b"Foo"14851486 rv = client.get("/", "http://localhost.localdomain:5000")1487 assert rv.data == b"Foo"14881489 rv = client.get("/", "https://localhost.localdomain:5000")1490 assert rv.data == b"Foo"14911492 app.config.update(SERVER_NAME="localhost.localdomain")1493 rv = client.get("/", "https://localhost.localdomain")1494 assert rv.data == b"Foo"14951496 try:1497 app.config.update(SERVER_NAME="localhost.localdomain:443")1498 rv = client.get("/", "https://localhost.localdomain")1499 # Werkzeug 0.81500 assert rv.status_code == 4041501 except ValueError as e:1502 # Werkzeug 0.71503 assert str(e) == (1504 "the server name provided "

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1507–1517why, one step back
1507 )
15081509 try:1510 app.config.update(SERVER_NAME="localhost.localdomain")1511 rv = client.get("/", "http://foo.localhost")1512 # Werkzeug 0.81513 assert rv.status_code == 4041514 except ValueError as e:1515 # Werkzeug 0.71516 assert str(e) == (1517 "the server name provided "

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1520–1525why, one step back
1520 )
15211522 rv = client.get("/", "http://foo.localhost.localdomain")1523 assert rv.data == b"Foo SubDomain"15241525

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1528–1531why, one step back
1528 @app.route("/")
1529 def index():1530 1 // 01531

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1532–1534why, one step back
1532 if config_key is not None:
1533 app.config[config_key] = True1534 with pytest.raises(Exception):

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

lines 1535–1538why, one step back
1535 client.get("/")
1536 else:1537 assert client.get("/").status_code == 5001538

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1544–1546why, one step back
1544 t = Thread(target=apprunner, args=(config_key,))
1545 t.start()1546 t.join()

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

lines 1547–1563why, one step back
1547
15481549@pytest.mark.parametrize("debug", [True, False])1550@pytest.mark.parametrize("use_debugger", [True, False])1551@pytest.mark.parametrize("use_reloader", [True, False])1552@pytest.mark.parametrize("propagate_exceptions", [None, True, False])1553def test_werkzeug_passthrough_errors(1554 monkeypatch, debug, use_debugger, use_reloader, propagate_exceptions, app1555):1556 rv = {}15571558 # Mocks werkzeug.serving.run_simple method1559 def run_simple_mock(*args, **kwargs):1560 rv["passthrough_errors"] = kwargs.get("passthrough_errors")15611562 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)1563 app.config["PROPAGATE_EXCEPTIONS"] = propagate_exceptions

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1565–1566why, one step back
1565
1566

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1568–1570why, one step back
1568 app.config["MAX_CONTENT_LENGTH"] = 64
15691570 @app.before_request

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1572–1575why, one step back
1572 flask.request.form["myfile"]
1573 assert False15741575 @app.route("/accept", methods=["POST"])

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1577–1579why, one step back
1577 flask.request.form["myfile"]
1578 assert False1579

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1582–1587why, one step back
1582 return "42"
15831584 rv = client.post("/accept", data={"myfile": "foo" * 100})1585 assert rv.data == b"42"15861587

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1588–1590why, one step back
1588def test_url_processors(app, client):
1589 @app.url_defaults1590 def add_language_code(endpoint, values):

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

lines 1591–1595why, one step back
1591 if flask.g.lang_code is not None and app.url_map.is_endpoint_expecting(
1592 endpoint, "lang_code"1593 ):1594 values.setdefault("lang_code", flask.g.lang_code)1595

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1598–1604why, one step back
1598 flask.g.lang_code = values.pop("lang_code", None)
15991600 @app.route("/<lang_code>/")1601 def index():1602 return flask.url_for("about")16031604 @app.route("/<lang_code>/about")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1606–1608why, one step back
1606 return flask.url_for("something_else")
16071608 @app.route("/foo")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1610–1616why, one step back
1610 return flask.url_for("about", lang_code="en")
16111612 assert client.get("/de/").data == b"/de/about"1613 assert client.get("/de/about").data == b"/foo"1614 assert client.get("/foo").data == b"/en/about"16151616

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1622–1624why, one step back
1622 values["page"] = "login"
16231624 @bp.route("/<page>")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1626–1627why, one step back
1626 pass
1627

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

line 1629why, one step back
1629

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1634–1637why, one step back
1634
1635 with app.test_request_context("/somepage"):1636 url = flask.url_for("foo.bar.baz.view")1637 expected = "/login"

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1639–1640why, one step back
1639
1640

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1642–1649why, one step back
1642 @app.route(u"/киртест")
1643 def index():1644 return "Hello World!"16451646 rv = client.get(u"/киртест")1647 assert rv.data == b"Hello World!"16481649

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1651–1656why, one step back
1651 app.debug = True
16521653 @app.route("/")1654 def index():1655 return "Awesome"1656

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1663–1669why, one step back
1663 return "Meh"
16641665 assert "A setup function was called" in str(e)16661667 app.debug = False16681669 @app.route("/foo")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1671–1676why, one step back
1671 return "Meh"
16721673 assert client.get("/foo").data == b"Meh"1674 assert app.got_first_request16751676

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1678–1690why, one step back
1678 got = []
16791680 @app.before_first_request1681 def foo():1682 got.append(42)16831684 client.get("/")1685 assert got == [42]1686 client.get("/")1687 assert got == [42]1688 assert app.got_first_request16891690

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1692–1695why, one step back
1692 got = []
16931694 @app.before_first_request1695 def foo():

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1697–1698why, one step back
1697 got.append(42)
1698

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

line 1702why, one step back
1702

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1703–1706why, one step back
1703 t = Thread(target=get_and_assert)
1704 t.start()1705 get_and_assert()1706 t.join()

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

lines 1707–1709why, one step back
1707 assert app.got_first_request
17081709

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1711–1717why, one step back
1711 app.debug = True
17121713 @app.route("/foo/", methods=["GET", "POST"])1714 def foo():1715 return "success"17161717 with client:

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1719–1731why, one step back
1719 client.post("/foo", data={})
1720 assert "http://localhost/foo/" in str(e)1721 assert ("Make sure to directly send " "your POST-request to this URL") in str(e)17221723 rv = client.get("/foo", data={}, follow_redirects=True)1724 assert rv.data == b"success"17251726 app.debug = False1727 with client:1728 rv = client.post("/foo", data={}, follow_redirects=True)1729 assert rv.data == b"success"17301731

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1733–1739why, one step back
1733 app.debug = True
17341735 @app.route("/foo/")1736 def foo():1737 return flask.request.endpoint17381739 @app.route("/bar/", endpoint="bar")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1741–1743why, one step back
1741 return flask.request.endpoint
17421743 @app.route("/bar/123", endpoint="123")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1745–1756why, one step back
1745 return flask.request.endpoint
17461747 with app.test_request_context():1748 assert flask.url_for("foo") == "/foo/"1749 assert flask.url_for("bar") == "/bar/"1750 assert flask.url_for("123") == "/bar/123"17511752 assert client.get("/foo/").data == b"foo"1753 assert client.get("/bar/").data == b"bar"1754 assert client.get("/bar/123").data == b"123"17551756

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1758–1763why, one step back
1758 app.debug = True
17591760 @app.route("/fail")1761 def fail_func():1762 1 // 01763

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1766–1767why, one step back
1766 client.get("/fail")
1767

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1768–1773why, one step back
1768 assert flask._request_ctx_stack.top is not None
1769 assert flask._app_ctx_stack.top is not None1770 # implicit appctx disappears too1771 flask._request_ctx_stack.top.pop()1772 assert flask._request_ctx_stack.top is None1773 assert flask._app_ctx_stack.top is None

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

lines 1774–1775why, one step back
1774
1775

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1779–1784why, one step back
1779
1780 @app.route("/fail")1781 def fail_func():1782 1 // 017831784 @app.route("/success")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1786–1788why, one step back
1786 return "Okay"
17871788 @app.teardown_request

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

line 1791why, one step back
1791

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

line 1796why, one step back
1796

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

line 1801why, one step back
1801

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1806–1807why, one step back
1806
1807

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1814–1815why, one step back
1814
1815

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1816–1818why, one step back
1816def test_g_iteration_protocol(app_ctx):
1817 flask.g.foo = 231818 flask.g.bar = 42

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

lines 1819–1823why, one step back
1819 assert "foo" in flask.g
1820 assert "foos" not in flask.g1821 assert sorted(flask.g) == ["bar", "foo"]18221823

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

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

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

lines 1825–1829why, one step back
1825 app = flask.Flask(__name__, subdomain_matching=True)
1826 app.config["SERVER_NAME"] = "localhost.localdomain"1827 client = app.test_client()18281829 @app.route("/")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1831–1833why, one step back
1831 return "normal index"
18321833 @app.route("/", subdomain="test")

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1835–1843why, one step back
1835 return "test index"
18361837 rv = client.get("/", "http://localhost.localdomain/")1838 assert rv.data == b"normal index"18391840 rv = client.get("/", "http://test.localhost.localdomain/")1841 assert rv.data == b"test index"18421843

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

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

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

lines 1845–1856why, one step back
1845 app = flask.Flask(__name__, subdomain_matching=True)
1846 client = app.test_client()1847 app.config["SERVER_NAME"] = "localhost.localdomain"18481849 @app.route("/", subdomain="<user>")1850 def index(user):1851 return "index for %s" % user18521853 rv = client.get("/", "http://mitsuhiko.localhost.localdomain/")1854 assert rv.data == b"index for mitsuhiko"18551856

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

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

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

lines 1858–1870why, one step back
1858 app = flask.Flask(__name__, subdomain_matching=True)
1859 app.config["SERVER_NAME"] = "localhost.localdomain:3000"1860 client = app.test_client()18611862 @app.route("/", subdomain="<user>")1863 def index(user):1864 return "index for %s" % user18651866 rv = client.get("/", "http://mitsuhiko.localhost.localdomain:3000/")1867 assert rv.data == b"index for mitsuhiko"186818691870@pytest.mark.parametrize("matching", (False, True))

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

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

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

lines 1873–1879why, one step back
1873 app.config["SERVER_NAME"] = "localhost.localdomain:3000"
1874 client = app.test_client()18751876 @app.route("/")1877 def index():1878 return "", 2041879

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

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

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

lines 1881–1883why, one step back
1881 rv = client.get("/", "http://127.0.0.1:3000/")
1882 assert rv.status_code == 404 if matching else 2041883

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

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

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

lines 1885–1888why, one step back
1885 rv = client.get("/", "http://www.localhost.localdomain:3000/")
1886 assert rv.status_code == 404 if matching else 20418871888

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1890–1892why, one step back
1890 @app.route("/")
1891 @app.route("/<test>/")1892 def index(test="a"):

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1893why, one step back
1893 return test

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

lines 1894–1900why, one step back
1894
1895 rv = client.open("/")1896 assert rv.data == b"a"1897 rv = client.open("/b/")1898 assert rv.data == b"b"18991900

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1901–1903why, one step back
1901def test_multi_route_class_views(app, client):
1902 class View(object):1903 def __init__(self, app):

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

lines 1904–1907why, one step back
1904 app.add_url_rule("/", "index", self.index)
1905 app.add_url_rule("/<test>/", "index", self.index)19061907 def index(self, test="a"):

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

line 1908why, one step back
1908 return test

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

line 1909why, one step back
1909

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1911–1916why, one step back
1911 rv = client.open("/")
1912 assert rv.data == b"a"1913 rv = client.open("/b/")1914 assert rv.data == b"b"19151916

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1918–1924why, one step back
1918 rv = {}
19191920 # Mocks werkzeug.serving.run_simple method1921 def run_simple_mock(*args, **kwargs):1922 rv["result"] = "running..."19231924 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1926–1928why, one step back
1926 assert rv["result"] == "running..."
19271928

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1930–1932why, one step back
1930 rv = {}
19311932 # Mocks werkzeug.serving.run_simple method

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

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

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1939–1942why, one step back
1939 assert rv["result"] == "running on %s:%s ..." % (hostname, port)
194019411942@pytest.mark.parametrize(

Merge pull request #2928 from vorelq/2926-default-port-overrides-zeroDavid Lordbefore adoptiond9fa28b

line 1943why, one step back
1943 "host,port,server_name,expect_host,expect_port",

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

line 1944why, one step back
1944 (

Merge pull request #2928 from vorelq/2926-default-port-overrides-zeroDavid Lordbefore adoptiond9fa28b

lines 1945–1951why, one step back
1945 (None, None, "pocoo.org:8080", "pocoo.org", 8080),
1946 ("localhost", None, "pocoo.org:8080", "localhost", 8080),1947 (None, 80, "pocoo.org:8080", "pocoo.org", 80),1948 ("localhost", 80, "pocoo.org:8080", "localhost", 80),1949 ("localhost", 0, "localhost:8080", "localhost", 0),1950 (None, None, "localhost:8080", "localhost", 8080),1951 (None, None, "localhost:0", "localhost", 0),

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

lines 1952–1953why, one step back
1952 ),
1953)

Fix style issues on master using BlackDaniel Popebefore adoptiona5ff3cd

lines 1954–1956why, one step back
1954def test_run_from_config(
1955 monkeypatch, host, port, server_name, expect_host, expect_port, app1956):

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

lines 1957–1959why, one step back
1957 def run_simple_mock(hostname, port, *args, **kwargs):
1958 assert hostname == expect_host1959 assert port == expect_port

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

lines 1960–1961why, one step back
1960
1961 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)

Merge pull request #2928 from vorelq/2926-default-port-overrides-zeroDavid Lordbefore adoptiond9fa28b

line 1962why, one step back
1962 app.config["SERVER_NAME"] = server_name

detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece

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

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

lines 1964–1965why, one step back
1964
1965

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

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

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

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

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

lines 1969–1971why, one step back
1969 # outside app context, default to Werkzeug static value,
1970 # which is also the default config1971 response = flask.Response()

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

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

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

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

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

line 1974why, one step back
1974

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

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

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

lines 1978–1982why, one step back
1978
1979 @app.route("/")1980 def index():1981 r = flask.Response("", status=204)1982 r.set_cookie("foo", "bar" * 100)

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

line 1983why, one step back
1983 return r

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

lines 1984–1985why, one step back
1984
1985 client.get("/")

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

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

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

lines 1988–1992why, one step back
1988 assert "cookie is too large" in str(w.message)
19891990 app.config["MAX_COOKIE_SIZE"] = 019911992 client.get("/")

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

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