Skip to content
Myr

test_basic.py

This file

Path

tests/test_basic.py

1,967 lines · 52.7 KiB · Python

Last changed by

Merge branch '1.0.x'David Lordbefore adoptionb05a685

History of this file

Take it

The walk stopped after 200 commits: lines older than 03a2996 point at it.

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

Merge branch '1.0.x'David Lordbefore adoption1351d0a

lines 8–9why, one step back
8 :copyright: 2010 Pallets
9 :license: BSD-3-Clause

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

lines 10–11why, one step back
10"""
11import re

Merge pull request #3195 from eruvanos/json_support_dataclassDavid Lordbefore adoptionb0185a6

line 12why, one step back
12import sys

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

lines 13–19why, one step back
13import time
14import uuid15from datetime import datetime16from threading import Thread1718import pytest19import werkzeug.serving

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

lines 20–22why, one step back
20from werkzeug.exceptions import BadRequest
21from werkzeug.exceptions import Forbidden22from werkzeug.exceptions import NotFound

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

lines 23–30why, one step back
23from werkzeug.http import parse_date
24from werkzeug.routing import BuildError2526import flask27from flask._compat import text_type282930def test_options_work(app, client):

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 47–52why, one step back
47 return "Aha!"
4849 rv = client.open("/", method="OPTIONS")50 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS", "POST", "PUT"]5152

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 76–82why, one step back
76 def index():
77 return flask.request.method7879 def more():80 return flask.request.method8182 app.add_url_rule("/", view_func=index, provide_automatic_options=False)

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 84–94why, one step back
84 "/more",
85 view_func=more,86 methods=["GET", "POST"],87 provide_automatic_options=False,88 )89 assert client.get("/").data == b"GET"9091 rv = client.post("/")92 assert rv.status_code == 40593 assert sorted(rv.allow) == ["GET", "HEAD"]94

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 96–120why, one step back
96 if hasattr(client, "options"):
97 rv = client.options("/")98 else:99 rv = client.open("/", method="OPTIONS")100101 assert rv.status_code == 405102103 rv = client.head("/")104 assert rv.status_code == 200105 assert not rv.data # head truncates106 assert client.post("/more").data == b"POST"107 assert client.get("/more").data == b"GET"108109 rv = client.delete("/more")110 assert rv.status_code == 405111 assert sorted(rv.allow) == ["GET", "HEAD", "POST"]112113 if hasattr(client, "options"):114 rv = client.options("/more")115 else:116 rv = client.open("/more", method="OPTIONS")117118 assert rv.status_code == 405119120

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 122–143why, one step back
122 @app.route("/")
123 def index():124 return flask.request.method125126 @app.route("/more", methods=["GET", "POST"])127 def more():128 return flask.request.method129130 assert client.get("/").data == b"GET"131 rv = client.post("/")132 assert rv.status_code == 405133 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS"]134 rv = client.head("/")135 assert rv.status_code == 200136 assert not rv.data # head truncates137 assert client.post("/more").data == b"POST"138 assert client.get("/more").data == b"GET"139 rv = client.delete("/more")140 assert rv.status_code == 405141 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS", "POST"]142143

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 150–151why, one step back
150
151

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 154–160why, one step back
154
155 def index():156 return flask.request.method157158 def more():159 return flask.request.method160

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

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

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

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

lines 169–184why, one step back
169 app.add_url_rule("/options", "options", options, methods=["options"])
170171 assert client.get("/").data == b"GET"172 rv = client.post("/")173 assert rv.status_code == 405174 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS"]175 rv = client.head("/")176 assert rv.status_code == 200177 assert not rv.data # head truncates178 assert client.post("/more").data == b"POST"179 assert client.get("/more").data == b"GET"180 rv = client.delete("/more")181 assert rv.status_code == 405182 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS", "POST"]183 rv = client.open("/options", method="OPTIONS")184 assert rv.status_code == 200

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 186–187why, one step back
186
187

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 189–207why, one step back
189 from werkzeug.routing import Submount, Rule
190191 app.url_map.add(192 Submount("/foo", [Rule("/bar", endpoint="bar"), Rule("/", endpoint="index")])193 )194195 def bar():196 return "bar"197198 def index():199 return "index"200201 app.view_functions["bar"] = bar202 app.view_functions["index"] = index203204 assert client.get("/foo/").data == b"index"205 assert client.get("/foo/bar").data == b"bar"206207

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 209–226why, one step back
209 from werkzeug.routing import Submount, Rule
210211 app.url_map.add(212 Submount("/foo", [Rule("/bar", endpoint="bar"), Rule("/", endpoint="index")])213 )214215 @app.endpoint("bar")216 def bar():217 return "bar"218219 @app.endpoint("index")220 def index():221 return "index"222223 assert client.get("/foo/").data == b"index"224 assert client.get("/foo/bar").data == b"bar"225226

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 230–233why, one step back
230 assert not flask.session.accessed
231 assert not flask.session.modified232 flask.session["value"] = flask.request.form["value"]233 assert flask.session.accessed

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 235–243why, one step back
235 return "value set"
236237 @app.route("/get")238 def get():239 assert not flask.session.accessed240 assert not flask.session.modified241 v = flask.session.get("value", "None")242 assert flask.session.accessed243 assert not flask.session.modified

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

line 244why, one step back
244 return v

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 251–262why, one step back
251 app.config.update(SERVER_NAME="example.com")
252253 @app.route("/")254 def index():255 flask.session["testing"] = 42256 return "Hello World"257258 rv = client.get("/", "http://example.com/")259 assert "domain=.example.com" in rv.headers["set-cookie"].lower()260 assert "httponly" in rv.headers["set-cookie"].lower()261262

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 264–275why, one step back
264 app.config.update(SERVER_NAME="example.com:8080")
265266 @app.route("/")267 def index():268 flask.session["testing"] = 42269 return "Hello World"270271 rv = client.get("/", "http://example.com:8080/")272 assert "domain=.example.com" in rv.headers["set-cookie"].lower()273 assert "httponly" in rv.headers["set-cookie"].lower()274275

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 277–289why, one step back
277 app.config.update(SERVER_NAME="example.com:8080", APPLICATION_ROOT="/foo")
278279 @app.route("/")280 def index():281 flask.session["testing"] = 42282 return "Hello World"283284 rv = client.get("/", "http://example.com:8080/foo")285 assert "domain=example.com" in rv.headers["set-cookie"].lower()286 assert "path=/foo" in rv.headers["set-cookie"].lower()287 assert "httponly" in rv.headers["set-cookie"].lower()288289

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

line 295why, one step back
295

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 299–311why, one step back
299
300 app.wsgi_app = PrefixPathMiddleware(app.wsgi_app, "/bar")301 app.config.update(APPLICATION_ROOT="/bar")302303 @app.route("/")304 def index():305 flask.session["testing"] = 42306 return "Hello World"307308 rv = client.get("/", "http://example.com:8080/")309 assert "path=/bar" in rv.headers["set-cookie"].lower()310311

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

lines 317–318why, one step back
317 SESSION_COOKIE_HTTPONLY=False,
318 SESSION_COOKIE_SECURE=True,

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

lines 319–336why, one step back
319 SESSION_COOKIE_SAMESITE="Lax",
320 SESSION_COOKIE_PATH="/",321 )322323 @app.route("/")324 def index():325 flask.session["testing"] = 42326 return "Hello World"327328 rv = client.get("/", "http://www.example.com:8080/test/")329 cookie = rv.headers["set-cookie"].lower()330 assert "domain=.example.com" in cookie331 assert "path=/" in cookie332 assert "secure" in cookie333 assert "httponly" not in cookie334 assert "samesite" in cookie335336

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 338–344why, one step back
338 @app.route("/")
339 def index():340 flask.session["testing"] = 42341 return "Hello World"342343 app.config.update(SESSION_COOKIE_SAMESITE="invalid")344

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 346–347why, one step back
346 client.get("/")
347

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 349–363why, one step back
349 rv = client.get("/")
350 cookie = rv.headers["set-cookie"].lower()351 assert "samesite" not in cookie352353 app.config.update(SESSION_COOKIE_SAMESITE="Strict")354 rv = client.get("/")355 cookie = rv.headers["set-cookie"].lower()356 assert "samesite=strict" in cookie357358 app.config.update(SESSION_COOKIE_SAMESITE="Lax")359 rv = client.get("/")360 cookie = rv.headers["set-cookie"].lower()361 assert "samesite=lax" in cookie362363

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 365–374why, one step back
365 app.config.update(SERVER_NAME="localhost:5000")
366367 @app.route("/")368 def index():369 flask.session["testing"] = 42370 return "testing"371372 rv = client.get("/", "http://localhost:5000/")373 assert "domain" not in rv.headers["set-cookie"].lower()374 w = recwarn.pop(UserWarning)

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 376–377why, one step back
376
377

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 379–391why, one step back
379 app.config.update(SERVER_NAME="127.0.0.1:5000")
380381 @app.route("/")382 def index():383 flask.session["testing"] = 42384 return "testing"385386 rv = client.get("/", "http://127.0.0.1:5000/")387 assert "domain=127.0.0.1" in rv.headers["set-cookie"].lower()388 w = recwarn.pop(UserWarning)389 assert "cookie domain is an IP" in str(w.message)390391

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

line 394why, one step back
394

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 397–404why, one step back
397 assert e.value.args and "session is unavailable" in e.value.args[0]
398399 with app.test_request_context():400 assert flask.session.get("missing_key") is None401 expect_exception(flask.session.__setitem__, "foo", 42)402 expect_exception(flask.session.pop, "foo")403404

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

lines 421–425why, one step back
421 expires = parse_date(match.group())
422 expected = datetime.utcnow() + app.permanent_session_lifetime423 assert expires.year == expected.year424 assert expires.month == expected.month425 assert expires.day == expected.day

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

line 430why, one step back
430 permanent = False

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 435–436why, one step back
435
436

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 440–450why, one step back
440 flask.session["foo"] = 42
441 return response442443 @app.route("/")444 def dump_session_contents():445 return repr(flask.session.get("foo"))446447 assert client.get("/").data == b"None"448 assert client.get("/").data == b"42"449450

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 454–468why, one step back
454
455 @app.route("/")456 def dump_session_contents():457 flask.session["t"] = (1, 2, 3)458 flask.session["b"] = b"\xff"459 flask.session["m"] = flask.Markup("<html>")460 flask.session["u"] = the_uuid461 flask.session["d"] = now462 flask.session["t_tag"] = {" t": "not-a-tuple"}463 flask.session["di_t_tag"] = {" t__": "not-a-tuple"}464 flask.session["di_tag"] = {" di": "not-a-dict"}465 return "", 204466467 with client:468 client.get("/")

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 470–481why, one step back
470 assert s["t"] == (1, 2, 3)
471 assert type(s["b"]) == bytes472 assert s["b"] == b"\xff"473 assert type(s["m"]) == flask.Markup474 assert s["m"] == flask.Markup("<html>")475 assert s["u"] == the_uuid476 assert s["d"] == now477 assert s["t_tag"] == {" t": "not-a-tuple"}478 assert s["di_t_tag"] == {" t__": "not-a-tuple"}479 assert s["di_tag"] == {" di": "not-a-dict"}480481

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 497–502why, one step back
497 assert c.get("/bump").data == b"1"
498 assert c.get("/bump").data == b"2"499 assert c.get("/bump").data == b"3"500501 rv = c.get("/read")502 set_cookie = rv.headers.get("set-cookie")

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 504–507why, one step back
504 assert rv.data == b"3"
505506 is_permanent = True507 app.config["SESSION_REFRESH_EACH_REQUEST"] = True

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 509–522why, one step back
509
510 is_permanent = True511 app.config["SESSION_REFRESH_EACH_REQUEST"] = False512 run_test(expect_header=False)513514 is_permanent = False515 app.config["SESSION_REFRESH_EACH_REQUEST"] = True516 run_test(expect_header=False)517518 is_permanent = False519 app.config["SESSION_REFRESH_EACH_REQUEST"] = False520 run_test(expect_header=False)521522

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 526–533why, one step back
526 flask.session["test"] = "test"
527 return ""528529 @app.route("/get")530 def get():531 return flask.session.get("test")532533 @app.route("/getitem")

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

line 561why, one step back
561

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 564–577why, one step back
564 assert len(rv.headers.get_all("Vary")) == 1
565 assert rv.headers["Vary"] == header_value566 else:567 assert "Vary" not in rv.headers568569 expect("/set")570 expect("/get")571 expect("/getitem")572 expect("/setdefault")573 expect("/vary-cookie-header-set")574 expect("/vary-header-set", "Accept-Encoding, Accept-Language, Cookie")575 expect("/no-vary-header", None)576577

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 650–667why, one step back
650
651 client = app.test_client()652 client.get("/")653 client.get("/test_with_categories/")654655 client = app.test_client()656 client.get("/")657 client.get("/test_filter/")658659 client = app.test_client()660 client.get("/")661 client.get("/test_filters/")662663 client = app.test_client()664 client.get("/")665 client.get("/test_filters_without_returning_categories/")666667

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 669–692why, one step back
669 evts = []
670671 @app.before_request672 def before_request():673 evts.append("before")674675 @app.after_request676 def after_request(response):677 response.data += b"|after"678 evts.append("after")679 return response680681 @app.route("/")682 def index():683 assert "before" in evts684 assert "after" not in evts685 return "request"686687 assert "after" not in evts688 rv = client.get("/").data689 assert "after" in evts690 assert rv == b"request|after"691692

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 699–700why, one step back
699
700 @app.before_request

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 704–705why, one step back
704
705 @app.before_request

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 718–719why, one step back
718
719

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

line 726why, one step back
726 return response

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

lines 727–730why, one step back
727
728 return "Test"729730 resp = client.get("/")

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 736–752why, one step back
736 called = []
737738 @app.teardown_request739 def teardown_request(exc):740 called.append(True)741 return "Ignored"742743 @app.route("/")744 def root():745 return "Response"746747 rv = client.get("/")748 assert rv.status_code == 200749 assert b"Response" in rv.data750 assert len(called) == 1751752

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 754–770why, one step back
754 called = []
755756 @app.teardown_request757 def teardown_request(exc):758 called.append(True)759 return "Ignored"760761 @app.route("/")762 def root():763 return "Response"764765 rv = client.get("/")766 assert rv.status_code == 200767 assert b"Response" in rv.data768 assert len(called) == 1769770

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 772–775why, one step back
772 called = []
773 app.testing = False774775 @app.teardown_request

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 777–783why, one step back
777 assert type(exc) == ZeroDivisionError
778 called.append(True)779 # This raises a new error and blows away sys.exc_info(), so we can780 # test that all teardown_requests get passed the same original781 # exception.782 try:783 raise TypeError()

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

line 784why, one step back
784 except Exception:

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

lines 785–787why, one step back
785 pass
786787 @app.teardown_request

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 789–795why, one step back
789 assert type(exc) == ZeroDivisionError
790 called.append(True)791 # This raises a new error and blows away sys.exc_info(), so we can792 # test that all teardown_requests get passed the same original793 # exception.794 try:795 raise TypeError()

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

line 796why, one step back
796 except Exception:

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

lines 797–799why, one step back
797 pass
798799 @app.route("/")

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 801–805why, one step back
801 1 // 0
802803 rv = client.get("/")804 assert rv.status_code == 500805 assert b"Internal Server Error" in rv.data

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 807–808why, one step back
807
808

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 815–816why, one step back
815
816 @app.before_request

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 819–820why, one step back
819
820 @app.after_request

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 823–825why, one step back
823 return response
824825 @app.after_request

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 828–830why, one step back
828 return response
829830 @app.teardown_request

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 833–834why, one step back
833
834 @app.teardown_request

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 837–843why, one step back
837
838 @app.route("/")839 def index():840 return "42"841842 rv = client.get("/")843 assert rv.data == b"42"

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 845–846why, one step back
845
846

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 852–857why, one step back
852 return "not found", 404
853854 @app.errorhandler(500)855 def internal_server_error(e):856 return "internal server error", 500857

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 860–866why, one step back
860 return "forbidden", 403
861862 @app.route("/")863 def index():864 flask.abort(404)865866 @app.route("/error")

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 872–880why, one step back
872 flask.abort(403)
873874 rv = client.get("/")875 assert rv.status_code == 404876 assert rv.data == b"not found"877 rv = client.get("/error")878 assert rv.status_code == 500879 assert b"internal server error" == rv.data880 rv = client.get("/forbidden")

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 893–903why, one step back
893 app.testing = False
894895 @app.errorhandler(500)896 def internal_server_error(e):897 return "internal server error", 500898899 @app.route("/")900 def broken_func():901 1 // 0902903 @app.after_request

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

line 906why, one step back
906 return resp

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

line 919why, one step back
919

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 921–922why, one step back
921 client.get("/")
922

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

lines 923–925why, one step back
923 ctx = flask._request_ctx_stack.top
924 assert ctx.preserved925 assert type(ctx._preserved_exc) is KeyboardInterrupt

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

lines 926–927why, one step back
926
927

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 936–941why, one step back
936
937 rv = client.get("/")938 assert rv.status_code == 404939 assert rv.data == b"value"940941

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 944–945why, one step back
944 pass
945

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 954–957why, one step back
954
955 assert client.get("/").data == b"42"956957

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 960–961why, one step back
960 pass
961

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 965–966why, one step back
965 return "banana"
966

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

lines 969–970why, one step back
969 assert not isinstance(e, ForbiddenSubclass)
970 assert isinstance(e, Forbidden)

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

lines 974–975why, one step back
974 def index1():
975 raise ForbiddenSubclass()

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

lines 982–983why, one step back
982 def index3():
983 raise Forbidden()

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 998–999why, one step back
998 pass
999

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1002–1003why, one step back
1002 return "E2"
1003

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

lines 1009–1010why, one step back
1009 def raise_e1():
1010 raise E1

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

lines 1013–1014why, one step back
1013 def raise_e3():
1014 raise E3

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

lines 1015–1022why, one step back
1015
1016 rv = client.get("/E1")1017 assert rv.data == b"Exception"10181019 rv = client.get("/E3")1020 assert rv.data == b"E2"10211022

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge branch '1.0-maintenance'David Lordbefore adoption1fa9185

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

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

lines 1031–1038why, one step back
1031
1032 rv = client.get("/key")1033 assert rv.status_code == 4001034 assert b"missing_key" not in rv.data1035 rv = client.get("/abort")1036 assert rv.status_code == 40010371038 app.debug = True

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1042–1047why, one step back
1042 assert "missing_key" in e.value.get_description()
1043 rv = client.get("/abort")1044 assert rv.status_code == 40010451046 app.debug = False1047 app.config["TRAP_BAD_REQUEST_ERRORS"] = True

Merge branch '1.0-maintenance'David Lordbefore adoption1fa9185

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

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

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

Merge branch '1.0-maintenance'David Lordbefore adoption1fa9185

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1055–1060why, one step back
1055 app.config["TRAP_HTTP_EXCEPTIONS"] = True
10561057 @app.route("/fail")1058 def fail():1059 flask.abort(404)1060

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1066–1069why, one step back
1066 app.testing = False
10671068 @app.before_request1069 def before_request():

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

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

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

lines 1071–1074why, one step back
1071 1 // 0
10721073 @app.after_request1074 def after_request(response):

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

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

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

lines 1076–1086why, one step back
1076 1 // 0
1077 return response10781079 @app.route("/")1080 def index():1081 return "Foo"10821083 @app.errorhandler(500)1084 def internal_server_error(e):1085 return "Hello Server Error", 5001086

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

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1095–1101why, one step back
1095
1096 app.debug = True10971098 @app.route("/fail", methods=["POST"])1099 def index():1100 return flask.request.files["foo"].filename1101

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

line 1105why, one step back
1105 with client:

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1110–1111why, one step back
1110
1111

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

lines 1149–1150why, one step back
1149 def from_wsgi():
1150 return NotFound()

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

line 1151why, one step back
1151

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

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

Merge pull request #3111 from pgjones/masterDavid Lordbefore adoption855d59b

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

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

line 1155why, one step back
1155

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

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

Merge pull request #3111 from pgjones/masterDavid Lordbefore adoption855d59b

line 1158why, one step back
1158

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

lines 1159–1188why, one step back
1159 rv = client.get("/full_tuple")
1160 assert rv.data == b"Meh"1161 assert rv.headers["X-Foo"] == "Testing"1162 assert rv.status_code == 4001163 assert rv.mimetype == "text/plain"11641165 rv = client.get("/text_headers")1166 assert rv.data == b"Hello"1167 assert rv.headers["X-Foo"] == "Test"1168 assert rv.status_code == 2001169 assert rv.mimetype == "text/plain"11701171 rv = client.get("/text_status")1172 assert rv.data == b"Hi, status!"1173 assert rv.status_code == 4001174 assert rv.mimetype == "text/html"11751176 rv = client.get("/response_headers")1177 assert rv.data == b"Hello world"1178 assert rv.headers.getlist("X-Foo") == ["Baz", "Bar"]1179 assert rv.headers["X-Bar"] == "Foo"1180 assert rv.status_code == 40411811182 rv = client.get("/response_status")1183 assert rv.data == b"Hello world"1184 assert rv.status_code == 50011851186 rv = client.get("/wsgi")1187 assert b"Not Found" in rv.data1188 assert rv.status_code == 404

Merge pull request #3111 from pgjones/masterDavid Lordbefore adoption855d59b

line 1189why, one step back
1189

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

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

Merge pull request #3111 from pgjones/masterDavid Lordbefore adoption855d59b

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

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

lines 1193–1194why, one step back
1193
1194

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1196–1199why, one step back
1196 app = flask.Flask(__name__)
1197 app.testing = True11981199 @app.route("/none")

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

lines 1212–1213why, one step back
1212 def from_bad_type():
1213 return True

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

lines 1216–1217why, one step back
1216 def from_bad_wsgi():
1217 return lambda: None

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

lines 1218–1222why, one step back
1218
1219 c = app.test_client()12201221 with pytest.raises(TypeError) as e:1222 c.get("/none")

Merge branch '1.0.x'David Lordbefore adoptionb05a685

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

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

lines 1224–1226why, one step back
1224
1225 with pytest.raises(TypeError) as e:1226 c.get("/small_tuple")

Merge branch '1.0.x'David Lordbefore adoptionb05a685

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

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

lines 1228–1232why, one step back
1228
1229 pytest.raises(TypeError, c.get, "/large_tuple")12301231 with pytest.raises(TypeError) as e:1232 c.get("/bad_type")

Merge branch '1.0.x'David Lordbefore adoptionb05a685

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

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

line 1234why, one step back
1234

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

lines 1235–1237why, one step back
1235 pytest.raises(TypeError, c.get, "/bad_wsgi")
12361237

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1240–1254why, one step back
1240 assert rv.status_code == 200
1241 assert rv.data == b""1242 assert rv.mimetype == "text/html"12431244 rv = flask.make_response("Awesome")1245 assert rv.status_code == 2001246 assert rv.data == b"Awesome"1247 assert rv.mimetype == "text/html"12481249 rv = flask.make_response("W00t", 404)1250 assert rv.status_code == 4041251 assert rv.data == b"W00t"1252 assert rv.mimetype == "text/html"12531254

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1259–1275why, one step back
1259 assert rv.mimetype == "application/json"
12601261 rv = flask.make_response(flask.Response(""), 400)1262 assert rv.status_code == 4001263 assert rv.data == b""1264 assert rv.mimetype == "text/html"12651266 rv = flask.make_response(1267 flask.Response("", headers={"Content-Type": "text/html"}),1268 400,1269 [("X-Foo", "bar")],1270 )1271 assert rv.status_code == 4001272 assert rv.headers["Content-Type"] == "text/html"1273 assert rv.headers["X-Foo"] == "bar"12741275

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1283–1284why, one step back
1283
1284

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

line 1288why, one step back
1288 pretty_response = (

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1294–1295why, one step back
1294
1295

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #3195 from eruvanos/json_support_dataclassDavid Lordbefore adoptionb0185a6

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

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

line 1306why, one step back
1306

Merge pull request #3195 from eruvanos/json_support_dataclassDavid Lordbefore adoptionb0185a6

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

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

line 1311why, one step back
1311

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

line 1312why, one step back
1312

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1322–1330why, one step back
1322 pass
13231324 assert flask.url_for("hello", name="test x") == "/hello/test%20x"1325 assert (1326 flask.url_for("hello", name="test x", _external=True)1327 == "http://localhost/hello/test%20x"1328 )13291330

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

line 1337why, one step back
1337 try:

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

lines 1340–1341why, one step back
1340 except BuildError as err:
1341 error = err

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

line 1344why, one step back
1344 except RuntimeError:

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1350–1351why, one step back
1350 return "/test_handler/"
1351

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1353–1356why, one step back
1353 with app.test_request_context():
1354 assert flask.url_for("spam") == "/test_handler/"13551356

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

line 1361why, one step back
1361

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1372–1382why, one step back
1372 "_external": False,
1373 "_anchor": None,1374 "_method": None,1375 "_scheme": None,1376 }1377 return "handled"13781379 with app.test_request_context():1380 flask.url_for("/")13811382

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1393–1402why, one step back
1393 app = flask.Flask(__name__, static_url_path="/foo")
1394 app.testing = True1395 rv = app.test_client().get("/foo/index.html")1396 assert rv.status_code == 2001397 rv.close()13981399 with app.test_request_context():1400 assert flask.url_for("static", filename="index.html") == "/foo/index.html"14011402

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

lines 1403–1413why, one step back
1403def test_static_url_path_with_ending_slash():
1404 app = flask.Flask(__name__, static_url_path="/foo/")1405 app.testing = True1406 rv = app.test_client().get("/foo/index.html")1407 assert rv.status_code == 2001408 rv.close()14091410 with app.test_request_context():1411 assert flask.url_for("static", filename="index.html") == "/foo/index.html"14121413

Merge pull request #3124 from elbeardmorez/fix_static_url_pathDavid Lordbefore adoption754b729

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

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

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

Merge pull request #3124 from elbeardmorez/fix_static_url_pathDavid Lordbefore adoption754b729

lines 1417–1421why, one step back
1417 assert rv.status_code == 200
1418 rv.close()141914201421def test_static_url_empty_path_default(app):

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

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

Merge pull request #3124 from elbeardmorez/fix_static_url_pathDavid Lordbefore adoption754b729

lines 1424–1427why, one step back
1424 assert rv.status_code == 200
1425 rv.close()14261427

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1429–1436why, one step back
1429 app = flask.Flask(__name__, host_matching=True, static_host="example.com")
1430 c = app.test_client()1431 rv = c.get("http://example.com/static/index.html")1432 assert rv.status_code == 2001433 rv.close()1434 with app.test_request_context():1435 rv = flask.url_for("static", filename="index.html", _external=True)1436 assert rv == "http://example.com/static/index.html"

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

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

lines 1440–1441why, one step back
1440 # Providing host_matching=True with static_folder
1441 # but without static_host should error.

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

line 1443why, one step back
1443 flask.Flask(__name__, host_matching=True)

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

lines 1444–1445why, one step back
1444 # Providing host_matching=True without static_host
1445 # but with static_folder=None should not error.

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

line 1446why, one step back
1446 flask.Flask(__name__, host_matching=True, static_folder=None)

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

lines 1447–1448why, one step back
1447
1448

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1452–1453why, one step back
1452
1453

Merge branch '1.0.x'David Lordbefore adoption29111a3

line 1454why, one step back
1454def test_server_name_subdomain():

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

lines 1455–1459why, one step back
1455 app = flask.Flask(__name__, subdomain_matching=True)
1456 client = app.test_client()14571458 @app.route("/")1459 def index():

Merge branch '1.0.x'David Lordbefore adoption29111a3

line 1460why, one step back
1460 return "default"

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

lines 1461–1462why, one step back
1461
1462 @app.route("/", subdomain="foo")

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

Merge branch '1.0.x'David Lordbefore adoption29111a3

line 1464why, one step back
1464 return "subdomain"

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

line 1465why, one step back
1465

Merge branch '1.0.x'David Lordbefore adoption29111a3

line 1466why, one step back
1466 app.config["SERVER_NAME"] = "dev.local:5000"

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

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

Merge branch '1.0.x'David Lordbefore adoption29111a3

line 1468why, one step back
1468 assert rv.data == b"default"

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

line 1469why, one step back
1469

Merge branch '1.0.x'David Lordbefore adoption29111a3

lines 1470–1471why, one step back
1470 rv = client.get("/", "http://dev.local:5000")
1471 assert rv.data == b"default"

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

line 1472why, one step back
1472

Merge branch '1.0.x'David Lordbefore adoption29111a3

lines 1473–1474why, one step back
1473 rv = client.get("/", "https://dev.local:5000")
1474 assert rv.data == b"default"

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

line 1475why, one step back
1475

Merge branch '1.0.x'David Lordbefore adoption29111a3

lines 1476–1477why, one step back
1476 app.config["SERVER_NAME"] = "dev.local:443"
1477 rv = client.get("/", "https://dev.local")

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

line 1478why, one step back
1478

Merge branch '1.0.x'David Lordbefore adoption29111a3

lines 1479–1481why, one step back
1479 # Werkzeug 1.0 fixes matching https scheme with 443 port
1480 if rv.status_code != 404:1481 assert rv.data == b"default"

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

line 1482why, one step back
1482

Merge branch '1.0.x'David Lordbefore adoption29111a3

lines 1483–1488why, one step back
1483 app.config["SERVER_NAME"] = "dev.local"
1484 rv = client.get("/", "https://dev.local")1485 assert rv.data == b"default"14861487 # suppress Werkzeug 1.0 warning about name mismatch1488 with pytest.warns(None):

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

lines 1489–1491why, one step back
1489 rv = client.get("/", "http://foo.localhost")
1490 assert rv.status_code == 4041491

Merge branch '1.0.x'David Lordbefore adoption29111a3

lines 1492–1493why, one step back
1492 rv = client.get("/", "http://foo.dev.local")
1493 assert rv.data == b"subdomain"

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

lines 1494–1495why, one step back
1494
1495

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1498–1501why, one step back
1498 @app.route("/")
1499 def index():1500 1 // 01501

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

lines 1502–1504why, one step back
1502 if config_key is not None:
1503 app.config[config_key] = True1504 with pytest.raises(Exception):

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

lines 1505–1508why, one step back
1505 client.get("/")
1506 else:1507 assert client.get("/").status_code == 5001508

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

lines 1514–1516why, one step back
1514 t = Thread(target=apprunner, args=(config_key,))
1515 t.start()1516 t.join()

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

lines 1517–1533why, one step back
1517
15181519@pytest.mark.parametrize("debug", [True, False])1520@pytest.mark.parametrize("use_debugger", [True, False])1521@pytest.mark.parametrize("use_reloader", [True, False])1522@pytest.mark.parametrize("propagate_exceptions", [None, True, False])1523def test_werkzeug_passthrough_errors(1524 monkeypatch, debug, use_debugger, use_reloader, propagate_exceptions, app1525):1526 rv = {}15271528 # Mocks werkzeug.serving.run_simple method1529 def run_simple_mock(*args, **kwargs):1530 rv["passthrough_errors"] = kwargs.get("passthrough_errors")15311532 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)1533 app.config["PROPAGATE_EXCEPTIONS"] = propagate_exceptions

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1535–1536why, one step back
1535
1536

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1538–1540why, one step back
1538 app.config["MAX_CONTENT_LENGTH"] = 64
15391540 @app.before_request

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

line 1542why, one step back
1542 flask.request.form["myfile"]

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

line 1543why, one step back
1543 AssertionError()

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

lines 1544–1545why, one step back
1544
1545 @app.route("/accept", methods=["POST"])

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

line 1547why, one step back
1547 flask.request.form["myfile"]

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

line 1548why, one step back
1548 AssertionError()

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

line 1549why, one step back
1549

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

lines 1558–1560why, one step back
1558def test_url_processors(app, client):
1559 @app.url_defaults1560 def add_language_code(endpoint, values):

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1576–1578why, one step back
1576 return flask.url_for("something_else")
15771578 @app.route("/foo")

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1580–1586why, one step back
1580 return flask.url_for("about", lang_code="en")
15811582 assert client.get("/de/").data == b"/de/about"1583 assert client.get("/de/about").data == b"/foo"1584 assert client.get("/foo").data == b"/en/about"15851586

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1592–1594why, one step back
1592 values["page"] = "login"
15931594 @bp.route("/<page>")

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1596–1597why, one step back
1596 pass
1597

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

line 1599why, one step back
1599

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1609–1610why, one step back
1609
1610

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1612–1619why, one step back
1612 @app.route(u"/киртест")
1613 def index():1614 return "Hello World!"16151616 rv = client.get(u"/киртест")1617 assert rv.data == b"Hello World!"16181619

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1621–1626why, one step back
1621 app.debug = True
16221623 @app.route("/")1624 def index():1625 return "Awesome"1626

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1633–1634why, one step back
1633 return "Meh"
1634

Merge branch '1.0.x'David Lordbefore adoptionb05a685

line 1635why, one step back
1635 assert "A setup function was called" in str(e.value)

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

lines 1636–1639why, one step back
1636
1637 app.debug = False16381639 @app.route("/foo")

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1641–1646why, one step back
1641 return "Meh"
16421643 assert client.get("/foo").data == b"Meh"1644 assert app.got_first_request16451646

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1648–1660why, one step back
1648 got = []
16491650 @app.before_first_request1651 def foo():1652 got.append(42)16531654 client.get("/")1655 assert got == [42]1656 client.get("/")1657 assert got == [42]1658 assert app.got_first_request16591660

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1662–1665why, one step back
1662 got = []
16631664 @app.before_first_request1665 def foo():

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1667–1668why, one step back
1667 got.append(42)
1668

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

line 1672why, one step back
1672

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

lines 1673–1676why, one step back
1673 t = Thread(target=get_and_assert)
1674 t.start()1675 get_and_assert()1676 t.join()

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

lines 1677–1679why, one step back
1677 assert app.got_first_request
16781679

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

line 1689why, one step back
1689 client.post("/foo", data={})

Merge branch '1.0.x'David Lordbefore adoptionb05a685

lines 1690–1693why, one step back
1690 assert "http://localhost/foo/" in str(e.value)
1691 assert ("Make sure to directly send your POST-request to this URL") in str(1692 e.value1693 )

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

lines 1694–1703why, one step back
1694
1695 rv = client.get("/foo", data={}, follow_redirects=True)1696 assert rv.data == b"success"16971698 app.debug = False1699 with client:1700 rv = client.post("/foo", data={}, follow_redirects=True)1701 assert rv.data == b"success"17021703

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1705–1711why, one step back
1705 app.debug = True
17061707 @app.route("/foo/")1708 def foo():1709 return flask.request.endpoint17101711 @app.route("/bar/", endpoint="bar")

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1713–1715why, one step back
1713 return flask.request.endpoint
17141715 @app.route("/bar/123", endpoint="123")

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1717–1728why, one step back
1717 return flask.request.endpoint
17181719 with app.test_request_context():1720 assert flask.url_for("foo") == "/foo/"1721 assert flask.url_for("bar") == "/bar/"1722 assert flask.url_for("123") == "/bar/123"17231724 assert client.get("/foo/").data == b"foo"1725 assert client.get("/bar/").data == b"bar"1726 assert client.get("/bar/123").data == b"123"17271728

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1730–1735why, one step back
1730 app.debug = True
17311732 @app.route("/fail")1733 def fail_func():1734 1 // 01735

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

line 1736why, one step back
1736 for _x in range(3):

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

line 1737why, one step back
1737 with pytest.raises(ZeroDivisionError):

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

lines 1738–1739why, one step back
1738 client.get("/fail")
1739

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

lines 1740–1745why, one step back
1740 assert flask._request_ctx_stack.top is not None
1741 assert flask._app_ctx_stack.top is not None1742 # implicit appctx disappears too1743 flask._request_ctx_stack.top.pop()1744 assert flask._request_ctx_stack.top is None1745 assert flask._app_ctx_stack.top is None

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

lines 1746–1747why, one step back
1746
1747

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1751–1756why, one step back
1751
1752 @app.route("/fail")1753 def fail_func():1754 1 // 017551756 @app.route("/success")

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1758–1760why, one step back
1758 return "Okay"
17591760 @app.teardown_request

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

line 1763why, one step back
1763

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

line 1768why, one step back
1768

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

line 1773why, one step back
1773

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1778–1779why, one step back
1778
1779

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1786–1787why, one step back
1786
1787

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

lines 1788–1790why, one step back
1788def test_g_iteration_protocol(app_ctx):
1789 flask.g.foo = 231790 flask.g.bar = 42

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

lines 1791–1795why, one step back
1791 assert "foo" in flask.g
1792 assert "foos" not in flask.g1793 assert sorted(flask.g) == ["bar", "foo"]17941795

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

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

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

lines 1797–1801why, one step back
1797 app = flask.Flask(__name__, subdomain_matching=True)
1798 app.config["SERVER_NAME"] = "localhost.localdomain"1799 client = app.test_client()18001801 @app.route("/")

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1803–1805why, one step back
1803 return "normal index"
18041805 @app.route("/", subdomain="test")

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1807–1815why, one step back
1807 return "test index"
18081809 rv = client.get("/", "http://localhost.localdomain/")1810 assert rv.data == b"normal index"18111812 rv = client.get("/", "http://test.localhost.localdomain/")1813 assert rv.data == b"test index"18141815

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

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

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

lines 1817–1828why, one step back
1817 app = flask.Flask(__name__, subdomain_matching=True)
1818 client = app.test_client()1819 app.config["SERVER_NAME"] = "localhost.localdomain"18201821 @app.route("/", subdomain="<user>")1822 def index(user):1823 return "index for %s" % user18241825 rv = client.get("/", "http://mitsuhiko.localhost.localdomain/")1826 assert rv.data == b"index for mitsuhiko"18271828

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

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

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

lines 1830–1842why, one step back
1830 app = flask.Flask(__name__, subdomain_matching=True)
1831 app.config["SERVER_NAME"] = "localhost.localdomain:3000"1832 client = app.test_client()18331834 @app.route("/", subdomain="<user>")1835 def index(user):1836 return "index for %s" % user18371838 rv = client.get("/", "http://mitsuhiko.localhost.localdomain:3000/")1839 assert rv.data == b"index for mitsuhiko"184018411842@pytest.mark.parametrize("matching", (False, True))

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

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

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

lines 1845–1851why, one step back
1845 app.config["SERVER_NAME"] = "localhost.localdomain:3000"
1846 client = app.test_client()18471848 @app.route("/")1849 def index():1850 return "", 2041851

Merge branch '1.0.x'David Lordbefore adoption29111a3

lines 1852–1856why, one step back
1852 # suppress Werkzeug 0.15 warning about name mismatch
1853 with pytest.warns(None):1854 # ip address can't match name1855 rv = client.get("/", "http://127.0.0.1:3000/")1856 assert rv.status_code == 404 if matching else 204

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

line 1857why, one step back
1857

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

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

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

lines 1859–1862why, one step back
1859 rv = client.get("/", "http://www.localhost.localdomain:3000/")
1860 assert rv.status_code == 404 if matching else 20418611862

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1864–1866why, one step back
1864 @app.route("/")
1865 @app.route("/<test>/")1866 def index(test="a"):

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

line 1867why, one step back
1867 return test

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

lines 1875–1877why, one step back
1875def test_multi_route_class_views(app, client):
1876 class View(object):1877 def __init__(self, app):

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

lines 1878–1881why, one step back
1878 app.add_url_rule("/", "index", self.index)
1879 app.add_url_rule("/<test>/", "index", self.index)18801881 def index(self, test="a"):

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

line 1882why, one step back
1882 return test

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

line 1883why, one step back
1883

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1885–1890why, one step back
1885 rv = client.open("/")
1886 assert rv.data == b"a"1887 rv = client.open("/b/")1888 assert rv.data == b"b"18891890

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1892–1898why, one step back
1892 rv = {}
18931894 # Mocks werkzeug.serving.run_simple method1895 def run_simple_mock(*args, **kwargs):1896 rv["result"] = "running..."18971898 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1900–1902why, one step back
1900 assert rv["result"] == "running..."
19011902

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1904–1906why, one step back
1904 rv = {}
19051906 # Mocks werkzeug.serving.run_simple method

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

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

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1913–1916why, one step back
1913 assert rv["result"] == "running on %s:%s ..." % (hostname, port)
191419151916@pytest.mark.parametrize(

Merge pull request #2928 from vorelq/2926-default-port-overrides-zeroDavid Lordbefore adoptiond9fa28b

line 1917why, one step back
1917 "host,port,server_name,expect_host,expect_port",

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

line 1918why, one step back
1918 (

Merge pull request #2928 from vorelq/2926-default-port-overrides-zeroDavid Lordbefore adoptiond9fa28b

lines 1919–1925why, one step back
1919 (None, None, "pocoo.org:8080", "pocoo.org", 8080),
1920 ("localhost", None, "pocoo.org:8080", "localhost", 8080),1921 (None, 80, "pocoo.org:8080", "pocoo.org", 80),1922 ("localhost", 80, "pocoo.org:8080", "localhost", 80),1923 ("localhost", 0, "localhost:8080", "localhost", 0),1924 (None, None, "localhost:8080", "localhost", 8080),1925 (None, None, "localhost:0", "localhost", 0),

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

lines 1926–1927why, one step back
1926 ),
1927)

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

lines 1928–1930why, one step back
1928def test_run_from_config(
1929 monkeypatch, host, port, server_name, expect_host, expect_port, app1930):

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

lines 1931–1933why, one step back
1931 def run_simple_mock(hostname, port, *args, **kwargs):
1932 assert hostname == expect_host1933 assert port == expect_port

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

lines 1934–1935why, one step back
1934
1935 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)

Merge pull request #2928 from vorelq/2926-default-port-overrides-zeroDavid Lordbefore adoptiond9fa28b

line 1936why, one step back
1936 app.config["SERVER_NAME"] = server_name

Merge pull request #2530 from pallets/feature/factory-detectionDavid Lordbefore adoption03a2996

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

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

lines 1938–1939why, one step back
1938
1939

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

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

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

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

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

lines 1943–1945why, one step back
1943 # outside app context, default to Werkzeug static value,
1944 # which is also the default config1945 response = flask.Response()

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

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

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

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

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

line 1948why, one step back
1948

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

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

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

lines 1952–1956why, one step back
1952
1953 @app.route("/")1954 def index():1955 r = flask.Response("", status=204)1956 r.set_cookie("foo", "bar" * 100)

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

line 1957why, one step back
1957 return r

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

lines 1958–1959why, one step back
1958
1959 client.get("/")

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

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

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

lines 1962–1966why, one step back
1962 assert "cookie is too large" in str(w.message)
19631964 app.config["MAX_COOKIE_SIZE"] = 019651966 client.get("/")

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

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