test_basic.py
This file
Path
tests/test_basic.py
1,955 lines · 52.4 KiB · Python
Last changed by
Merge pull request #3182 from qil026/issue-3134-url-joinDavid Lordbefore adoptiondbd3840
History of this fileTake it
The walk stopped after 200 commits: lines older than 6162ece point at it.
detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1–7why, one step back1# -*- coding: utf-8 -*-2"""3 tests.basic4 ~~~~~~~~~~~~~~~~~~~~~56 The basic functionality.7Merge pull request #2624 from pallets/metadataDavid Lordbefore adoption4309c7c
line 8why, one step back8 :copyright: © 2010 by the Pallets team.detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 9–28why, one step back9 :license: BSD, see LICENSE for more details.10"""1112import re13import time14import uuid15from datetime import datetime16from threading import Thread1718import pytest19import werkzeug.serving20from werkzeug.exceptions import BadRequest, Forbidden, NotFound21from werkzeug.http import parse_date22from werkzeug.routing import BuildError2324import flask25from flask._compat import text_type262728def test_options_work(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 29–37why, one step back29 @app.route("/", methods=["GET", "POST"])30 def index():31 return "Hello World"3233 rv = client.open("/", method="OPTIONS")34 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS", "POST"]35 assert rv.data == b""3637detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 38why, one step back38def test_options_on_multiple_rules(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 39–43why, one step back39 @app.route("/", methods=["GET", "POST"])40 def index():41 return "Hello World"4243 @app.route("/", methods=["PUT"])detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 44why, one step back44 def index_put():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 45–50why, one step back45 return "Aha!"4647 rv = client.open("/", method="OPTIONS")48 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS", "POST", "PUT"]4950detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 51why, one step back51def test_provide_automatic_options_attr():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 52–56why, one step back52 app = flask.Flask(__name__)5354 def index():55 return "Hello World!"56detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 57why, one step back57 index.provide_automatic_options = FalseMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 58–66why, one step back58 app.route("/")(index)59 rv = app.test_client().open("/", method="OPTIONS")60 assert rv.status_code == 4056162 app = flask.Flask(__name__)6364 def index2():65 return "Hello World!"66detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 67why, one step back67 index2.provide_automatic_options = TrueMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 68–72why, one step back68 app.route("/", methods=["OPTIONS"])(index2)69 rv = app.test_client().open("/", method="OPTIONS")70 assert sorted(rv.allow) == ["OPTIONS"]7172detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 73why, one step back73def test_provide_automatic_options_kwarg(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 74–80why, one step back74 def index():75 return flask.request.method7677 def more():78 return flask.request.method7980 app.add_url_rule("/", view_func=index, provide_automatic_options=False)detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 81why, one step back81 app.add_url_rule(Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 82–92why, one step back82 "/more",83 view_func=more,84 methods=["GET", "POST"],85 provide_automatic_options=False,86 )87 assert client.get("/").data == b"GET"8889 rv = client.post("/")90 assert rv.status_code == 40591 assert sorted(rv.allow) == ["GET", "HEAD"]92detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 93why, one step back93 # Older versions of Werkzeug.test.Client don't have an options methodMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 94–118why, one step back94 if hasattr(client, "options"):95 rv = client.options("/")96 else:97 rv = client.open("/", method="OPTIONS")9899 assert rv.status_code == 405100101 rv = client.head("/")102 assert rv.status_code == 200103 assert not rv.data # head truncates104 assert client.post("/more").data == b"POST"105 assert client.get("/more").data == b"GET"106107 rv = client.delete("/more")108 assert rv.status_code == 405109 assert sorted(rv.allow) == ["GET", "HEAD", "POST"]110111 if hasattr(client, "options"):112 rv = client.options("/more")113 else:114 rv = client.open("/more", method="OPTIONS")115116 assert rv.status_code == 405117118detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 119why, one step back119def test_request_dispatching(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 120–141why, one step back120 @app.route("/")121 def index():122 return flask.request.method123124 @app.route("/more", methods=["GET", "POST"])125 def more():126 return flask.request.method127128 assert client.get("/").data == b"GET"129 rv = client.post("/")130 assert rv.status_code == 405131 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS"]132 rv = client.head("/")133 assert rv.status_code == 200134 assert not rv.data # head truncates135 assert client.post("/more").data == b"POST"136 assert client.get("/more").data == b"GET"137 rv = client.delete("/more")138 assert rv.status_code == 405139 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS", "POST"]140141detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 142–143why, one step back142def test_disallow_string_for_allowed_methods(app):143 with pytest.raises(TypeError):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 144–146why, one step back144145 @app.route("/", methods="GET POST")146 def index():detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 147why, one step back147 return "Hey"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 148–149why, one step back148149detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 150–151why, one step back150def test_url_mapping(app, client):151 random_uuid4 = "7eb41166-9ebf-4d26-b771-ea3f54f8b383"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 152–158why, one step back152153 def index():154 return flask.request.method155156 def more():157 return flask.request.method158detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 159–160why, one step back159 def options():160 return random_uuid4Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 161–164why, one step back161162 app.add_url_rule("/", "index", index)163 app.add_url_rule("/more", "more", more, methods=["GET", "POST"])164detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 165why, one step back165 # Issue 1288: Test that automatic options are not added when non-uppercase 'options' in methodsMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 166–181why, one step back166 app.add_url_rule("/options", "options", options, methods=["options"])167168 assert client.get("/").data == b"GET"169 rv = client.post("/")170 assert rv.status_code == 405171 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS"]172 rv = client.head("/")173 assert rv.status_code == 200174 assert not rv.data # head truncates175 assert client.post("/more").data == b"POST"176 assert client.get("/more").data == b"GET"177 rv = client.delete("/more")178 assert rv.status_code == 405179 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS", "POST"]180 rv = client.open("/options", method="OPTIONS")181 assert rv.status_code == 200detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 182why, one step back182 assert random_uuid4 in rv.data.decode("utf-8")Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 183–184why, one step back183184detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 185why, one step back185def test_werkzeug_routing(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 186–204why, one step back186 from werkzeug.routing import Submount, Rule187188 app.url_map.add(189 Submount("/foo", [Rule("/bar", endpoint="bar"), Rule("/", endpoint="index")])190 )191192 def bar():193 return "bar"194195 def index():196 return "index"197198 app.view_functions["bar"] = bar199 app.view_functions["index"] = index200201 assert client.get("/foo/").data == b"index"202 assert client.get("/foo/bar").data == b"bar"203204detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 205why, one step back205def test_endpoint_decorator(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 206–223why, one step back206 from werkzeug.routing import Submount, Rule207208 app.url_map.add(209 Submount("/foo", [Rule("/bar", endpoint="bar"), Rule("/", endpoint="index")])210 )211212 @app.endpoint("bar")213 def bar():214 return "bar"215216 @app.endpoint("index")217 def index():218 return "index"219220 assert client.get("/foo/").data == b"index"221 assert client.get("/foo/bar").data == b"bar"222223detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 224why, one step back224def test_session(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 225why, one step back225 @app.route("/set", methods=["POST"])detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 226why, one step back226 def set():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 227–230why, one step back227 assert not flask.session.accessed228 assert not flask.session.modified229 flask.session["value"] = flask.request.form["value"]230 assert flask.session.accessedMerge pull request #2580 from pallets/session-attrsDavid Lordbefore adoption26f413e
line 231why, one step back231 assert flask.session.modifiedMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 232–240why, one step back232 return "value set"233234 @app.route("/get")235 def get():236 assert not flask.session.accessed237 assert not flask.session.modified238 v = flask.session.get("value", "None")239 assert flask.session.accessed240 assert not flask.session.modifiedMerge pull request #2580 from pallets/session-attrsDavid Lordbefore adoption26f413e
line 241why, one step back241 return vMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 242–246why, one step back242243 assert client.post("/set", data={"value": "42"}).data == b"value set"244 assert client.get("/get").data == b"42"245246detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 247why, one step back247def test_session_using_server_name(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 248–259why, one step back248 app.config.update(SERVER_NAME="example.com")249250 @app.route("/")251 def index():252 flask.session["testing"] = 42253 return "Hello World"254255 rv = client.get("/", "http://example.com/")256 assert "domain=.example.com" in rv.headers["set-cookie"].lower()257 assert "httponly" in rv.headers["set-cookie"].lower()258259detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 260why, one step back260def test_session_using_server_name_and_port(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 261–272why, one step back261 app.config.update(SERVER_NAME="example.com:8080")262263 @app.route("/")264 def index():265 flask.session["testing"] = 42266 return "Hello World"267268 rv = client.get("/", "http://example.com:8080/")269 assert "domain=.example.com" in rv.headers["set-cookie"].lower()270 assert "httponly" in rv.headers["set-cookie"].lower()271272detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 273why, one step back273def test_session_using_server_name_port_and_path(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 274–286why, one step back274 app.config.update(SERVER_NAME="example.com:8080", APPLICATION_ROOT="/foo")275276 @app.route("/")277 def index():278 flask.session["testing"] = 42279 return "Hello World"280281 rv = client.get("/", "http://example.com:8080/foo")282 assert "domain=example.com" in rv.headers["set-cookie"].lower()283 assert "path=/foo" in rv.headers["set-cookie"].lower()284 assert "httponly" in rv.headers["set-cookie"].lower()285286detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 287–291why, one step back287def test_session_using_application_root(app, client):288 class PrefixPathMiddleware(object):289 def __init__(self, app, prefix):290 self.app = app291 self.prefix = prefixMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 292why, one step back292detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 293why, one step back293 def __call__(self, environ, start_response):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 294why, one step back294 environ["SCRIPT_NAME"] = self.prefixdetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 295why, one step back295 return self.app(environ, start_response)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 296–308why, one step back296297 app.wsgi_app = PrefixPathMiddleware(app.wsgi_app, "/bar")298 app.config.update(APPLICATION_ROOT="/bar")299300 @app.route("/")301 def index():302 flask.session["testing"] = 42303 return "Hello World"304305 rv = client.get("/", "http://example.com:8080/")306 assert "path=/bar" in rv.headers["set-cookie"].lower()307308detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 309why, one step back309def test_session_using_session_settings(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 310–313why, one step back310 app.config.update(311 SERVER_NAME="www.example.com:8080",312 APPLICATION_ROOT="/test",313 SESSION_COOKIE_DOMAIN=".example.com",detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 314–315why, one step back314 SESSION_COOKIE_HTTPONLY=False,315 SESSION_COOKIE_SECURE=True,Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 316–333why, one step back316 SESSION_COOKIE_SAMESITE="Lax",317 SESSION_COOKIE_PATH="/",318 )319320 @app.route("/")321 def index():322 flask.session["testing"] = 42323 return "Hello World"324325 rv = client.get("/", "http://www.example.com:8080/test/")326 cookie = rv.headers["set-cookie"].lower()327 assert "domain=.example.com" in cookie328 assert "path=/" in cookie329 assert "secure" in cookie330 assert "httponly" not in cookie331 assert "samesite" in cookie332333Merge pull request #2607 from FadhelC/SameSite-cookie-featureDavid Lordbefore adoptione21abd9
line 334why, one step back334def test_session_using_samesite_attribute(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 335–341why, one step back335 @app.route("/")336 def index():337 flask.session["testing"] = 42338 return "Hello World"339340 app.config.update(SESSION_COOKIE_SAMESITE="invalid")341Merge pull request #2607 from FadhelC/SameSite-cookie-featureDavid Lordbefore adoptione21abd9
line 342why, one step back342 with pytest.raises(ValueError):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 343–344why, one step back343 client.get("/")344Merge pull request #2607 from FadhelC/SameSite-cookie-featureDavid Lordbefore adoptione21abd9
line 345why, one step back345 app.config.update(SESSION_COOKIE_SAMESITE=None)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 346–360why, one step back346 rv = client.get("/")347 cookie = rv.headers["set-cookie"].lower()348 assert "samesite" not in cookie349350 app.config.update(SESSION_COOKIE_SAMESITE="Strict")351 rv = client.get("/")352 cookie = rv.headers["set-cookie"].lower()353 assert "samesite=strict" in cookie354355 app.config.update(SESSION_COOKIE_SAMESITE="Lax")356 rv = client.get("/")357 cookie = rv.headers["set-cookie"].lower()358 assert "samesite=lax" in cookie359360detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 361why, one step back361def test_session_localhost_warning(recwarn, app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 362–371why, one step back362 app.config.update(SERVER_NAME="localhost:5000")363364 @app.route("/")365 def index():366 flask.session["testing"] = 42367 return "testing"368369 rv = client.get("/", "http://localhost:5000/")370 assert "domain" not in rv.headers["set-cookie"].lower()371 w = recwarn.pop(UserWarning)detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 372why, one step back372 assert '"localhost" is not a valid cookie domain' in str(w.message)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 373–374why, one step back373374detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 375why, one step back375def test_session_ip_warning(recwarn, app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 376–388why, one step back376 app.config.update(SERVER_NAME="127.0.0.1:5000")377378 @app.route("/")379 def index():380 flask.session["testing"] = 42381 return "testing"382383 rv = client.get("/", "http://127.0.0.1:5000/")384 assert "domain=127.0.0.1" in rv.headers["set-cookie"].lower()385 w = recwarn.pop(UserWarning)386 assert "cookie domain is an IP" in str(w.message)387388detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 389–390why, one step back389def test_missing_session(app):390 app.secret_key = NoneMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 391why, one step back391detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 392–393why, one step back392 def expect_exception(f, *args, **kwargs):393 e = pytest.raises(RuntimeError, f, *args, **kwargs)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 394–401why, one step back394 assert e.value.args and "session is unavailable" in e.value.args[0]395396 with app.test_request_context():397 assert flask.session.get("missing_key") is None398 expect_exception(flask.session.__setitem__, "foo", 42)399 expect_exception(flask.session.pop, "foo")400401detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 402–403why, one step back402def test_session_expiration(app, client):403 permanent = TrueMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 404–407why, one step back404405 @app.route("/")406 def index():407 flask.session["test"] = 42detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 408why, one step back408 flask.session.permanent = permanentMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 409–412why, one step back409 return ""410411 @app.route("/test")412 def test():detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 413why, one step back413 return text_type(flask.session.permanent)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 414–417why, one step back414415 rv = client.get("/")416 assert "set-cookie" in rv.headers417 match = re.search(r"(?i)\bexpires=([^;]+)", rv.headers["set-cookie"])detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 418–422why, one step back418 expires = parse_date(match.group())419 expected = datetime.utcnow() + app.permanent_session_lifetime420 assert expires.year == expected.year421 assert expires.month == expected.month422 assert expires.day == expected.dayMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 423–426why, one step back423424 rv = client.get("/test")425 assert rv.data == b"True"426detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 427why, one step back427 permanent = FalseMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 428–430why, one step back428 rv = client.get("/")429 assert "set-cookie" in rv.headers430 match = re.search(r"\bexpires=([^;]+)", rv.headers["set-cookie"])detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 431why, one step back431 assert match is NoneMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 432–433why, one step back432433detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 434why, one step back434def test_session_stored_last(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 435why, one step back435 @app.after_requestdetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 436why, one step back436 def modify_session(response):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 437–447why, one step back437 flask.session["foo"] = 42438 return response439440 @app.route("/")441 def dump_session_contents():442 return repr(flask.session.get("foo"))443444 assert client.get("/").data == b"None"445 assert client.get("/").data == b"42"446447detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 448–450why, one step back448def test_session_special_types(app, client):449 now = datetime.utcnow().replace(microsecond=0)450 the_uuid = uuid.uuid4()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 451–465why, one step back451452 @app.route("/")453 def dump_session_contents():454 flask.session["t"] = (1, 2, 3)455 flask.session["b"] = b"\xff"456 flask.session["m"] = flask.Markup("<html>")457 flask.session["u"] = the_uuid458 flask.session["d"] = now459 flask.session["t_tag"] = {" t": "not-a-tuple"}460 flask.session["di_t_tag"] = {" t__": "not-a-tuple"}461 flask.session["di_tag"] = {" di": "not-a-dict"}462 return "", 204463464 with client:465 client.get("/")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 466why, one step back466 s = flask.sessionMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 467–478why, one step back467 assert s["t"] == (1, 2, 3)468 assert type(s["b"]) == bytes469 assert s["b"] == b"\xff"470 assert type(s["m"]) == flask.Markup471 assert s["m"] == flask.Markup("<html>")472 assert s["u"] == the_uuid473 assert s["d"] == now474 assert s["t_tag"] == {" t": "not-a-tuple"}475 assert s["di_t_tag"] == {" t__": "not-a-tuple"}476 assert s["di_tag"] == {" di": "not-a-dict"}477478detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 479why, one step back479def test_session_cookie_setting(app):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 480–482why, one step back480 is_permanent = True481482 @app.route("/bump")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 483why, one step back483 def bump():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 484why, one step back484 rv = flask.session["foo"] = flask.session.get("foo", 0) + 1detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 485–486why, one step back485 flask.session.permanent = is_permanent486 return str(rv)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 487–488why, one step back487488 @app.route("/read")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 489why, one step back489 def read():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 490–491why, one step back490 return str(flask.session.get("foo", 0))491detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 492–493why, one step back492 def run_test(expect_header):493 with app.test_client() as c:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 494–499why, one step back494 assert c.get("/bump").data == b"1"495 assert c.get("/bump").data == b"2"496 assert c.get("/bump").data == b"3"497498 rv = c.get("/read")499 set_cookie = rv.headers.get("set-cookie")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 500why, one step back500 assert (set_cookie is not None) == expect_headerMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 501–504why, one step back501 assert rv.data == b"3"502503 is_permanent = True504 app.config["SESSION_REFRESH_EACH_REQUEST"] = Truedetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 505why, one step back505 run_test(expect_header=True)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 506–519why, one step back506507 is_permanent = True508 app.config["SESSION_REFRESH_EACH_REQUEST"] = False509 run_test(expect_header=False)510511 is_permanent = False512 app.config["SESSION_REFRESH_EACH_REQUEST"] = True513 run_test(expect_header=False)514515 is_permanent = False516 app.config["SESSION_REFRESH_EACH_REQUEST"] = False517 run_test(expect_header=False)518519detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 520why, one step back520def test_session_vary_cookie(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 521why, one step back521 @app.route("/set")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 522why, one step back522 def set_session():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 523–530why, one step back523 flask.session["test"] = "test"524 return ""525526 @app.route("/get")527 def get():528 return flask.session.get("test")529530 @app.route("/getitem")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 531why, one step back531 def getitem():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 532–534why, one step back532 return flask.session["test"]533534 @app.route("/setdefault")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 535why, one step back535 def setdefault():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 536–538why, one step back536 return flask.session.setdefault("test", "default")537538 @app.route("/vary-cookie-header-set")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 539why, one step back539 def vary_cookie_header_set():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 540–545why, one step back540 response = flask.Response()541 response.vary.add("Cookie")542 flask.session["test"] = "test"543 return response544545 @app.route("/vary-header-set")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 546why, one step back546 def vary_header_set():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 547–552why, one step back547 response = flask.Response()548 response.vary.update(("Accept-Encoding", "Accept-Language"))549 flask.session["test"] = "test"550 return response551552 @app.route("/no-vary-header")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 553why, one step back553 def no_vary_header():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 554–556why, one step back554 return ""555556 def expect(path, header_value="Cookie"):detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 557why, one step back557 rv = client.get(path)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 558why, one step back558detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 559–560why, one step back559 if header_value:560 # The 'Vary' key should exist in the headers only once.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 561–574why, one step back561 assert len(rv.headers.get_all("Vary")) == 1562 assert rv.headers["Vary"] == header_value563 else:564 assert "Vary" not in rv.headers565566 expect("/set")567 expect("/get")568 expect("/getitem")569 expect("/setdefault")570 expect("/vary-cookie-header-set")571 expect("/vary-header-set", "Accept-Encoding, Accept-Language, Cookie")572 expect("/no-vary-header", None)573574detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 575–576why, one step back575def test_flashes(app, req_ctx):576 assert not flask.session.modifiedMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 577why, one step back577 flask.flash("Zap")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 578why, one step back578 flask.session.modified = FalseMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 579why, one step back579 flask.flash("Zip")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 580why, one step back580 assert flask.session.modifiedMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 581–583why, one step back581 assert list(flask.get_flashed_messages()) == ["Zap", "Zip"]582583detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 584–589why, one step back584def test_extended_flashing(app):585 # Be sure app.testing=True below, else tests can fail silently.586 #587 # Specifically, if app.testing is not set to True, the AssertionErrors588 # in the view functions will cause a 500 response to the test client589 # instead of propagating exceptions.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 590–599why, one step back590591 @app.route("/")592 def index():593 flask.flash(u"Hello World")594 flask.flash(u"Hello World", "error")595 flask.flash(flask.Markup(u"<em>Testing</em>"), "warning")596 return ""597598 @app.route("/test/")599 def test():detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 600why, one step back600 messages = flask.get_flashed_messages()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 601–608why, one step back601 assert list(messages) == [602 u"Hello World",603 u"Hello World",604 flask.Markup(u"<em>Testing</em>"),605 ]606 return ""607608 @app.route("/test_with_categories/")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 609–611why, one step back609 def test_with_categories():610 messages = flask.get_flashed_messages(with_categories=True)611 assert len(messages) == 3Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 612–619why, one step back612 assert list(messages) == [613 ("message", u"Hello World"),614 ("error", u"Hello World"),615 ("warning", flask.Markup(u"<em>Testing</em>")),616 ]617 return ""618619 @app.route("/test_filter/")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 620why, one step back620 def test_filter():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 621–627why, one step back621 messages = flask.get_flashed_messages(622 category_filter=["message"], with_categories=True623 )624 assert list(messages) == [("message", u"Hello World")]625 return ""626627 @app.route("/test_filters/")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 628why, one step back628 def test_filters():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 629–638why, one step back629 messages = flask.get_flashed_messages(630 category_filter=["message", "warning"], with_categories=True631 )632 assert list(messages) == [633 ("message", u"Hello World"),634 ("warning", flask.Markup(u"<em>Testing</em>")),635 ]636 return ""637638 @app.route("/test_filters_without_returning_categories/")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 639why, one step back639 def test_filters2():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 640why, one step back640 messages = flask.get_flashed_messages(category_filter=["message", "warning"])detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 641why, one step back641 assert len(messages) == 2Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 642–645why, one step back642 assert messages[0] == u"Hello World"643 assert messages[1] == flask.Markup(u"<em>Testing</em>")644 return ""645detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 646why, one step back646 # Create new test client on each test to clean flashed messages.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 647–664why, one step back647648 client = app.test_client()649 client.get("/")650 client.get("/test_with_categories/")651652 client = app.test_client()653 client.get("/")654 client.get("/test_filter/")655656 client = app.test_client()657 client.get("/")658 client.get("/test_filters/")659660 client = app.test_client()661 client.get("/")662 client.get("/test_filters_without_returning_categories/")663664detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 665why, one step back665def test_request_processing(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 666–689why, one step back666 evts = []667668 @app.before_request669 def before_request():670 evts.append("before")671672 @app.after_request673 def after_request(response):674 response.data += b"|after"675 evts.append("after")676 return response677678 @app.route("/")679 def index():680 assert "before" in evts681 assert "after" not in evts682 return "request"683684 assert "after" not in evts685 rv = client.get("/").data686 assert "after" in evts687 assert rv == b"request|after"688689detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 690why, one step back690def test_request_preprocessing_early_return(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 691–693why, one step back691 evts = []692693 @app.before_requestdetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 694–695why, one step back694 def before_request1():695 evts.append(1)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 696–697why, one step back696697 @app.before_requestdetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 698–700why, one step back698 def before_request2():699 evts.append(2)700 return "hello"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 701–702why, one step back701702 @app.before_requestdetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 703–705why, one step back703 def before_request3():704 evts.append(3)705 return "bye"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 706–709why, one step back706707 @app.route("/")708 def index():709 evts.append("index")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 710why, one step back710 return "damnit"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 711–713why, one step back711712 rv = client.get("/").data.strip()713 assert rv == b"hello"detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 714why, one step back714 assert evts == [1, 2]Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 715–716why, one step back715716detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 717why, one step back717def test_after_request_processing(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 718–719why, one step back718 @app.route("/")719 def index():detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 720–721why, one step back720 @flask.after_this_request721 def foo(response):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 722why, one step back722 response.headers["X-Foo"] = "a header"detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 723why, one step back723 return responseMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 724–727why, one step back724725 return "Test"726727 resp = client.get("/")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 728why, one step back728 assert resp.status_code == 200Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 729–731why, one step back729 assert resp.headers["X-Foo"] == "a header"730731detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 732why, one step back732def test_teardown_request_handler(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 733–749why, one step back733 called = []734735 @app.teardown_request736 def teardown_request(exc):737 called.append(True)738 return "Ignored"739740 @app.route("/")741 def root():742 return "Response"743744 rv = client.get("/")745 assert rv.status_code == 200746 assert b"Response" in rv.data747 assert len(called) == 1748749detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 750why, one step back750def test_teardown_request_handler_debug_mode(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 751–767why, one step back751 called = []752753 @app.teardown_request754 def teardown_request(exc):755 called.append(True)756 return "Ignored"757758 @app.route("/")759 def root():760 return "Response"761762 rv = client.get("/")763 assert rv.status_code == 200764 assert b"Response" in rv.data765 assert len(called) == 1766767detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 768why, one step back768def test_teardown_request_handler_error(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 769–772why, one step back769 called = []770 app.testing = False771772 @app.teardown_requestdetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 773why, one step back773 def teardown_request1(exc):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 774–784why, one step back774 assert type(exc) == ZeroDivisionError775 called.append(True)776 # This raises a new error and blows away sys.exc_info(), so we can777 # test that all teardown_requests get passed the same original778 # exception.779 try:780 raise TypeError()781 except:782 pass783784 @app.teardown_requestdetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 785why, one step back785 def teardown_request2(exc):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 786–796why, one step back786 assert type(exc) == ZeroDivisionError787 called.append(True)788 # This raises a new error and blows away sys.exc_info(), so we can789 # test that all teardown_requests get passed the same original790 # exception.791 try:792 raise TypeError()793 except:794 pass795796 @app.route("/")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 797why, one step back797 def fails():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 798–802why, one step back798 1 // 0799800 rv = client.get("/")801 assert rv.status_code == 500802 assert b"Internal Server Error" in rv.datadetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 803why, one step back803 assert len(called) == 2Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 804–805why, one step back804805detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 806why, one step back806def test_before_after_request_order(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 807–809why, one step back807 called = []808809 @app.before_requestdetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 810–811why, one step back810 def before1():811 called.append(1)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 812–813why, one step back812813 @app.before_requestdetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 814–815why, one step back814 def before2():815 called.append(2)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 816–817why, one step back816817 @app.after_requestdetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 818–819why, one step back818 def after1(response):819 called.append(4)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 820–822why, one step back820 return response821822 @app.after_requestdetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 823–824why, one step back823 def after2(response):824 called.append(3)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 825–827why, one step back825 return response826827 @app.teardown_requestdetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 828–829why, one step back828 def finish1(exc):829 called.append(6)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 830–831why, one step back830831 @app.teardown_requestdetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 832–833why, one step back832 def finish2(exc):833 called.append(5)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 834–840why, one step back834835 @app.route("/")836 def index():837 return "42"838839 rv = client.get("/")840 assert rv.data == b"42"detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 841why, one step back841 assert called == [1, 2, 3, 4, 5, 6]Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 842–843why, one step back842843detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 844why, one step back844def test_error_handling(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 845–847why, one step back845 app.testing = False846847 @app.errorhandler(404)detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 848why, one step back848 def not_found(e):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 849–854why, one step back849 return "not found", 404850851 @app.errorhandler(500)852 def internal_server_error(e):853 return "internal server error", 500854detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 855–856why, one step back855 @app.errorhandler(Forbidden)856 def forbidden(e):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 857–863why, one step back857 return "forbidden", 403858859 @app.route("/")860 def index():861 flask.abort(404)862863 @app.route("/error")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 864why, one step back864 def error():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 865–867why, one step back865 1 // 0866867 @app.route("/forbidden")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 868why, one step back868 def error2():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 869–877why, one step back869 flask.abort(403)870871 rv = client.get("/")872 assert rv.status_code == 404873 assert rv.data == b"not found"874 rv = client.get("/error")875 assert rv.status_code == 500876 assert b"internal server error" == rv.data877 rv = client.get("/forbidden")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 878why, one step back878 assert rv.status_code == 403Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 879–881why, one step back879 assert b"forbidden" == rv.data880881detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 882–883why, one step back882def test_error_handler_unknown_code(app):883 with pytest.raises(KeyError) as exc_info:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 884–888why, one step back884 app.register_error_handler(999, lambda e: ("999", 999))885886 assert "Use a subclass" in exc_info.value.args[0]887888detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 889why, one step back889def test_error_handling_processing(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 890–900why, one step back890 app.testing = False891892 @app.errorhandler(500)893 def internal_server_error(e):894 return "internal server error", 500895896 @app.route("/")897 def broken_func():898 1 // 0899900 @app.after_requestdetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 901why, one step back901 def after_request(resp):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 902why, one step back902 resp.mimetype = "text/x-special"detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 903why, one step back903 return respMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 904–909why, one step back904905 resp = client.get("/")906 assert resp.mimetype == "text/x-special"907 assert resp.data == b"internal server error"908909detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 910why, one step back910def test_baseexception_error_handling(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 911–914why, one step back911 app.testing = False912913 @app.route("/")914 def broken_func():detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 915why, one step back915 raise KeyboardInterrupt()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 916why, one step back916detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 917why, one step back917 with pytest.raises(KeyboardInterrupt):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 918–919why, one step back918 client.get("/")919detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 920–922why, one step back920 ctx = flask._request_ctx_stack.top921 assert ctx.preserved922 assert type(ctx._preserved_exc) is KeyboardInterruptMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 923–924why, one step back923924detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 925why, one step back925def test_before_request_and_routing_errors(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 926why, one step back926 @app.before_requestdetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 927why, one step back927 def attach_something():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 928–930why, one step back928 flask.g.something = "value"929930 @app.errorhandler(404)detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 931–932why, one step back931 def return_something(error):932 return flask.g.something, 404Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 933–938why, one step back933934 rv = client.get("/")935 assert rv.status_code == 404936 assert rv.data == b"value"937938detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 939–940why, one step back939def test_user_error_handling(app, client):940 class MyException(Exception):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 941–942why, one step back941 pass942detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 943–945why, one step back943 @app.errorhandler(MyException)944 def handle_my_exception(e):945 assert isinstance(e, MyException)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 946–949why, one step back946 return "42"947948 @app.route("/")949 def index():detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 950why, one step back950 raise MyException()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 951–954why, one step back951952 assert client.get("/").data == b"42"953954detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 955–956why, one step back955def test_http_error_subclass_handling(app, client):956 class ForbiddenSubclass(Forbidden):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 957–958why, one step back957 pass958detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 959why, one step back959 @app.errorhandler(ForbiddenSubclass)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 960why, one step back960 def handle_forbidden_subclass(e):detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 961why, one step back961 assert isinstance(e, ForbiddenSubclass)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 962–963why, one step back962 return "banana"963detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 964why, one step back964 @app.errorhandler(403)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 965why, one step back965 def handle_forbidden_subclass(e):detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 966–967why, one step back966 assert not isinstance(e, ForbiddenSubclass)967 assert isinstance(e, Forbidden)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 968–970why, one step back968 return "apple"969970 @app.route("/1")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 971–972why, one step back971 def index1():972 raise ForbiddenSubclass()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 973–978why, one step back973974 @app.route("/2")975 def index2():976 flask.abort(403)977978 @app.route("/3")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 979–980why, one step back979 def index3():980 raise Forbidden()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 981–986why, one step back981982 assert client.get("/1").data == b"banana"983 assert client.get("/2").data == b"apple"984 assert client.get("/3").data == b"apple"985986detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 987–988why, one step back987def test_errorhandler_precedence(app, client):988 class E1(Exception):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 989–990why, one step back989 pass990detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 991why, one step back991 class E2(Exception):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 992–993why, one step back992 pass993detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 994why, one step back994 class E3(E1, E2):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 995–996why, one step back995 pass996detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 997–998why, one step back997 @app.errorhandler(E2)998 def handle_e2(e):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 999–1000why, one step back999 return "E2"1000detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1001–1002why, one step back1001 @app.errorhandler(Exception)1002 def handle_exception(e):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1003–1005why, one step back1003 return "Exception"10041005 @app.route("/E1")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1006–1007why, one step back1006 def raise_e1():1007 raise E1Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1008–1009why, one step back10081009 @app.route("/E3")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1010–1011why, one step back1010 def raise_e3():1011 raise E3Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1012–1019why, one step back10121013 rv = client.get("/E1")1014 assert rv.data == b"Exception"10151016 rv = client.get("/E3")1017 assert rv.data == b"E2"10181019detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1020why, one step back1020def test_trapping_of_bad_request_key_errors(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1021–1025why, one step back1021 @app.route("/key")1022 def fail():1023 flask.request.form["missing_key"]10241025 @app.route("/abort")Merge branch '1.0-maintenance'David Lordbefore adoption1fa9185
lines 1026–1027why, one step back1026 def allow_abort():1027 flask.abort(400)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1028–1035why, one step back10281029 rv = client.get("/key")1030 assert rv.status_code == 4001031 assert b"missing_key" not in rv.data1032 rv = client.get("/abort")1033 assert rv.status_code == 40010341035 app.debug = Truedetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1036why, one step back1036 with pytest.raises(KeyError) as e:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1037why, one step back1037 client.get("/key")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1038why, one step back1038 assert e.errisinstance(BadRequest)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1039–1044why, one step back1039 assert "missing_key" in e.value.get_description()1040 rv = client.get("/abort")1041 assert rv.status_code == 40010421043 app.debug = False1044 app.config["TRAP_BAD_REQUEST_ERRORS"] = TrueMerge branch '1.0-maintenance'David Lordbefore adoption1fa9185
line 1045why, one step back1045 with pytest.raises(KeyError):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1046why, one step back1046 client.get("/key")Merge branch '1.0-maintenance'David Lordbefore adoption1fa9185
line 1047why, one step back1047 with pytest.raises(BadRequest):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1048–1050why, one step back1048 client.get("/abort")10491050detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1051why, one step back1051def test_trapping_of_all_http_exceptions(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1052–1057why, one step back1052 app.config["TRAP_HTTP_EXCEPTIONS"] = True10531054 @app.route("/fail")1055 def fail():1056 flask.abort(404)1057detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1058why, one step back1058 with pytest.raises(NotFound):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1059–1061why, one step back1059 client.get("/fail")10601061Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469
line 1062why, one step back1062def test_error_handler_after_processor_error(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1063–1085why, one step back1063 app.testing = False10641065 @app.before_request1066 def before_request():1067 if trigger == "before":1068 1 // 010691070 @app.after_request1071 def after_request(response):1072 if trigger == "after":1073 1 // 01074 return response10751076 @app.route("/")1077 def index():1078 return "Foo"10791080 @app.errorhandler(500)1081 def internal_server_error(e):1082 return "Hello Server Error", 50010831084 for trigger in "before", "after":1085 rv = client.get("/")Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469
line 1086why, one step back1086 assert rv.status_code == 500Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1087–1089why, one step back1087 assert rv.data == b"Hello Server Error"10881089detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1090–1091why, one step back1090def test_enctype_debug_helper(app, client):1091 from flask.debughelpers import DebugFilesKeyErrorMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1092–1098why, one step back10921093 app.debug = True10941095 @app.route("/fail", methods=["POST"])1096 def index():1097 return flask.request.files["foo"].filename1098detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1099–1101why, one step back1099 # with statement is important because we leave an exception on the1100 # stack otherwise and we want to ensure that this is not the case1101 # to not negatively affect other tests.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1102why, one step back1102 with client:detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1103why, one step back1103 with pytest.raises(DebugFilesKeyError) as e:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1104–1105why, one step back1104 client.post("/fail", data={"foo": "index.txt"})1105 assert "no file contents were transmitted" in str(e.value)detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1106why, one step back1106 assert 'This was submitted: "index.txt"' in str(e.value)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1107–1108why, one step back11071108detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1109why, one step back1109def test_response_types(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1110why, one step back1110 @app.route("/text")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1111why, one step back1111 def from_text():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1112–1114why, one step back1112 return u"Hällo Wörld"11131114 @app.route("/bytes")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1115why, one step back1115 def from_bytes():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1116–1118why, one step back1116 return u"Hällo Wörld".encode("utf-8")11171118 @app.route("/full_tuple")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1119why, one step back1119 def from_full_tuple():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1120–1126why, one step back1120 return (1121 "Meh",1122 400,1123 {"X-Foo": "Testing", "Content-Type": "text/plain; charset=utf-8"},1124 )11251126 @app.route("/text_headers")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1127why, one step back1127 def from_text_headers():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1128–1130why, one step back1128 return "Hello", {"X-Foo": "Test", "Content-Type": "text/plain; charset=utf-8"}11291130 @app.route("/text_status")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1131why, one step back1131 def from_text_status():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1132–1134why, one step back1132 return "Hi, status!", 40011331134 @app.route("/response_headers")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1135why, one step back1135 def from_response_headers():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1136–1141why, one step back1136 return (1137 flask.Response("Hello world", 404, {"X-Foo": "Baz"}),1138 {"X-Foo": "Bar", "X-Bar": "Foo"},1139 )11401141 @app.route("/response_status")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1142why, one step back1142 def from_response_status():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1143–1145why, one step back1143 return app.response_class("Hello world", 400), 50011441145 @app.route("/wsgi")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1146–1147why, one step back1146 def from_wsgi():1147 return NotFound()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1148–1183why, one step back11481149 assert client.get("/text").data == u"Hällo Wörld".encode("utf-8")1150 assert client.get("/bytes").data == u"Hällo Wörld".encode("utf-8")11511152 rv = client.get("/full_tuple")1153 assert rv.data == b"Meh"1154 assert rv.headers["X-Foo"] == "Testing"1155 assert rv.status_code == 4001156 assert rv.mimetype == "text/plain"11571158 rv = client.get("/text_headers")1159 assert rv.data == b"Hello"1160 assert rv.headers["X-Foo"] == "Test"1161 assert rv.status_code == 2001162 assert rv.mimetype == "text/plain"11631164 rv = client.get("/text_status")1165 assert rv.data == b"Hi, status!"1166 assert rv.status_code == 4001167 assert rv.mimetype == "text/html"11681169 rv = client.get("/response_headers")1170 assert rv.data == b"Hello world"1171 assert rv.headers.getlist("X-Foo") == ["Baz", "Bar"]1172 assert rv.headers["X-Bar"] == "Foo"1173 assert rv.status_code == 40411741175 rv = client.get("/response_status")1176 assert rv.data == b"Hello world"1177 assert rv.status_code == 50011781179 rv = client.get("/wsgi")1180 assert b"Not Found" in rv.data1181 assert rv.status_code == 40411821183detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1184why, one step back1184def test_response_type_errors():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1185–1188why, one step back1185 app = flask.Flask(__name__)1186 app.testing = True11871188 @app.route("/none")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1189why, one step back1189 def from_none():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1190–1192why, one step back1190 pass11911192 @app.route("/small_tuple")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1193why, one step back1193 def from_small_tuple():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1194–1196why, one step back1194 return ("Hello",)11951196 @app.route("/large_tuple")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1197why, one step back1197 def from_large_tuple():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1198–1200why, one step back1198 return "Hello", 234, {"X-Foo": "Bar"}, "???"11991200 @app.route("/bad_type")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1201–1202why, one step back1201 def from_bad_type():1202 return TrueMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1203–1204why, one step back12031204 @app.route("/bad_wsgi")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1205–1206why, one step back1205 def from_bad_wsgi():1206 return lambda: NoneMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1207–1226why, one step back12071208 c = app.test_client()12091210 with pytest.raises(TypeError) as e:1211 c.get("/none")1212 assert "returned None" in str(e)12131214 with pytest.raises(TypeError) as e:1215 c.get("/small_tuple")1216 assert "tuple must have the form" in str(e)12171218 pytest.raises(TypeError, c.get, "/large_tuple")12191220 with pytest.raises(TypeError) as e:1221 c.get("/bad_type")1222 assert "it was a bool" in str(e)12231224 pytest.raises(TypeError, c.get, "/bad_wsgi")12251226detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1227–1228why, one step back1227def test_make_response(app, req_ctx):1228 rv = flask.make_response()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1229–1243why, one step back1229 assert rv.status_code == 2001230 assert rv.data == b""1231 assert rv.mimetype == "text/html"12321233 rv = flask.make_response("Awesome")1234 assert rv.status_code == 2001235 assert rv.data == b"Awesome"1236 assert rv.mimetype == "text/html"12371238 rv = flask.make_response("W00t", 404)1239 assert rv.status_code == 4041240 assert rv.data == b"W00t"1241 assert rv.mimetype == "text/html"12421243detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1244why, one step back1244def test_make_response_with_response_instance(app, req_ctx):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1245–1246why, one step back1245 rv = flask.make_response(flask.jsonify({"msg": "W00t"}), 400)1246 assert rv.status_code == 400detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1247why, one step back1247 assert rv.data == b'{"msg":"W00t"}\n'Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1248–1264why, one step back1248 assert rv.mimetype == "application/json"12491250 rv = flask.make_response(flask.Response(""), 400)1251 assert rv.status_code == 4001252 assert rv.data == b""1253 assert rv.mimetype == "text/html"12541255 rv = flask.make_response(1256 flask.Response("", headers={"Content-Type": "text/html"}),1257 400,1258 [("X-Foo", "bar")],1259 )1260 assert rv.status_code == 4001261 assert rv.headers["Content-Type"] == "text/html"1262 assert rv.headers["X-Foo"] == "bar"12631264detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1265–1267why, one step back1265def test_jsonify_no_prettyprint(app, req_ctx):1266 app.config.update({"JSONIFY_PRETTYPRINT_REGULAR": False})1267 compressed_msg = b'{"msg":{"submsg":"W00t"},"msg2":"foobar"}\n'Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1268–1270why, one step back1268 uncompressed_msg = {"msg": {"submsg": "W00t"}, "msg2": "foobar"}12691270 rv = flask.make_response(flask.jsonify(uncompressed_msg), 200)detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1271why, one step back1271 assert rv.data == compressed_msgMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1272–1273why, one step back12721273detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1274–1276why, one step back1274def test_jsonify_prettyprint(app, req_ctx):1275 app.config.update({"JSONIFY_PRETTYPRINT_REGULAR": True})1276 compressed_msg = {"msg": {"submsg": "W00t"}, "msg2": "foobar"}Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1277why, one step back1277 pretty_response = (detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1278why, one step back1278 b'{\n "msg": {\n "submsg": "W00t"\n }, \n "msg2": "foobar"\n}\n'Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1279–1281why, one step back1279 )12801281 rv = flask.make_response(flask.jsonify(compressed_msg), 200)detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1282why, one step back1282 assert rv.data == pretty_responseMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1283–1284why, one step back12831284detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1285why, one step back1285def test_jsonify_mimetype(app, req_ctx):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1286–1291why, one step back1286 app.config.update({"JSONIFY_MIMETYPE": "application/vnd.api+json"})1287 msg = {"msg": {"submsg": "W00t"}}1288 rv = flask.make_response(flask.jsonify(msg), 200)1289 assert rv.mimetype == "application/vnd.api+json"12901291detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1292why, one step back1292def test_jsonify_args_and_kwargs_check(app, req_ctx):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1293–1297why, one step back1293 with pytest.raises(TypeError) as e:1294 flask.jsonify("fake args", kwargs="fake")1295 assert "behavior undefined" in str(e.value)12961297detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1298why, one step back1298def test_url_generation(app, req_ctx):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1299why, one step back1299 @app.route("/hello/<name>", methods=["POST"])detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1300why, one step back1300 def hello():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1301–1309why, one step back1301 pass13021303 assert flask.url_for("hello", name="test x") == "/hello/test%20x"1304 assert (1305 flask.url_for("hello", name="test x", _external=True)1306 == "http://localhost/hello/test%20x"1307 )13081309detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1310–1311why, one step back1310def test_build_error_handler(app):1311 # Test base case, a URL which results in a BuildError.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1312–1314why, one step back1312 with app.test_request_context():1313 pytest.raises(BuildError, flask.url_for, "spam")1314detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1315why, one step back1315 # Verify the error is re-raised if not the current exception.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1316why, one step back1316 try:detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1317why, one step back1317 with app.test_request_context():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1318why, one step back1318 flask.url_for("spam")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1319–1320why, one step back1319 except BuildError as err:1320 error = errMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1321–1322why, one step back1321 try:1322 raise RuntimeError("Test case where BuildError is not current.")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1323why, one step back1323 except RuntimeError:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1324–1325why, one step back1324 pytest.raises(BuildError, app.handle_url_build_error, error, "spam", {})1325detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1326why, one step back1326 # Test a custom handler.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1327why, one step back1327 def handler(error, endpoint, values):detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1328why, one step back1328 # Just a test.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1329–1330why, one step back1329 return "/test_handler/"1330detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1331why, one step back1331 app.url_build_error_handlers.append(handler)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1332–1335why, one step back1332 with app.test_request_context():1333 assert flask.url_for("spam") == "/test_handler/"13341335detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1336–1339why, one step back1336def test_build_error_handler_reraise(app):1337 # Test a custom handler which reraises the BuildError1338 def handler_raises_build_error(error, endpoint, values):1339 raise errorMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1340why, one step back1340detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1341why, one step back1341 app.url_build_error_handlers.append(handler_raises_build_error)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1342–1346why, one step back13421343 with app.test_request_context():1344 pytest.raises(BuildError, flask.url_for, "not.existing")13451346detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1347–1348why, one step back1347def test_url_for_passes_special_values_to_build_error_handler(app):1348 @app.url_build_error_handlers.appendMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1349why, one step back1349 def handler(error, endpoint, values):detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1350why, one step back1350 assert values == {Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1351–1361why, one step back1351 "_external": False,1352 "_anchor": None,1353 "_method": None,1354 "_scheme": None,1355 }1356 return "handled"13571358 with app.test_request_context():1359 flask.url_for("/")13601361detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1362–1363why, one step back1362def test_custom_converters(app, client):1363 from werkzeug.routing import BaseConverterMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1364why, one step back1364detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1365–1366why, one step back1365 class ListConverter(BaseConverter):1366 def to_python(self, value):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1367–1368why, one step back1367 return value.split(",")1368detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1369–1370why, one step back1369 def to_url(self, value):1370 base_to_url = super(ListConverter, self).to_urlMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1371–1375why, one step back1371 return ",".join(base_to_url(x) for x in value)13721373 app.url_map.converters["list"] = ListConverter13741375 @app.route("/<list:args>")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1376why, one step back1376 def index(args):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1377–1381why, one step back1377 return "|".join(args)13781379 assert client.get("/1,2,3").data == b"1|2|3"13801381detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1382why, one step back1382def test_static_files(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1383–1390why, one step back1383 rv = client.get("/static/index.html")1384 assert rv.status_code == 2001385 assert rv.data.strip() == b"<h1>Hello World!</h1>"1386 with app.test_request_context():1387 assert flask.url_for("static", filename="index.html") == "/static/index.html"1388 rv.close()13891390detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1391why, one step back1391def test_static_url_path():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1392–1401why, one step back1392 app = flask.Flask(__name__, static_url_path="/foo")1393 app.testing = True1394 rv = app.test_client().get("/foo/index.html")1395 assert rv.status_code == 2001396 rv.close()13971398 with app.test_request_context():1399 assert flask.url_for("static", filename="index.html") == "/foo/index.html"14001401Merge pull request #3182 from qil026/issue-3134-url-joinDavid Lordbefore adoptiondbd3840
lines 1402–1412why, one step back1402def test_static_url_path_with_ending_slash():1403 app = flask.Flask(__name__, static_url_path="/foo/")1404 app.testing = True1405 rv = app.test_client().get("/foo/index.html")1406 assert rv.status_code == 2001407 rv.close()14081409 with app.test_request_context():1410 assert flask.url_for("static", filename="index.html") == "/foo/index.html"14111412detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1413why, one step back1413def test_static_route_with_host_matching():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1414–1421why, one step back1414 app = flask.Flask(__name__, host_matching=True, static_host="example.com")1415 c = app.test_client()1416 rv = c.get("http://example.com/static/index.html")1417 assert rv.status_code == 2001418 rv.close()1419 with app.test_request_context():1420 rv = flask.url_for("static", filename="index.html", _external=True)1421 assert rv == "http://example.com/static/index.html"detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1422why, one step back1422 # Providing static_host without host_matching=True should error.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1423–1424why, one step back1423 with pytest.raises(Exception):1424 flask.Flask(__name__, static_host="example.com")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1425why, one step back1425 # Providing host_matching=True with static_folder but without static_host should error.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1426why, one step back1426 with pytest.raises(Exception):detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1427–1429why, one step back1427 flask.Flask(__name__, host_matching=True)1428 # Providing host_matching=True without static_host but with static_folder=None should not error.1429 flask.Flask(__name__, host_matching=True, static_folder=None)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1430–1431why, one step back14301431detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1432why, one step back1432def test_request_locals():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1433why, one step back1433 assert repr(flask.g) == "<LocalProxy unbound>"detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1434why, one step back1434 assert not flask.gMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1435–1436why, one step back14351436Merge pull request #2635 from pallets/feature/server-name-routingDavid Lordbefore adoptionf808c20
line 1437why, one step back1437def test_test_app_proper_environ():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1438–1446why, one step back1438 app = flask.Flask(__name__, subdomain_matching=True)1439 app.config.update(SERVER_NAME="localhost.localdomain:5000")1440 client = app.test_client()14411442 @app.route("/")1443 def index():1444 return "Foo"14451446 @app.route("/", subdomain="foo")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1447why, one step back1447 def subdomain():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1448–1471why, one step back1448 return "Foo SubDomain"14491450 rv = client.get("/")1451 assert rv.data == b"Foo"14521453 rv = client.get("/", "http://localhost.localdomain:5000")1454 assert rv.data == b"Foo"14551456 rv = client.get("/", "https://localhost.localdomain:5000")1457 assert rv.data == b"Foo"14581459 app.config.update(SERVER_NAME="localhost.localdomain")1460 rv = client.get("/", "https://localhost.localdomain")1461 assert rv.data == b"Foo"14621463 try:1464 app.config.update(SERVER_NAME="localhost.localdomain:443")1465 rv = client.get("/", "https://localhost.localdomain")1466 # Werkzeug 0.81467 assert rv.status_code == 4041468 except ValueError as e:1469 # Werkzeug 0.71470 assert str(e) == (1471 "the server name provided "detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1472–1473why, one step back1472 "('localhost.localdomain:443') does not match the "1473 "server name from the WSGI environment ('localhost.localdomain')"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1474–1484why, one step back1474 )14751476 try:1477 app.config.update(SERVER_NAME="localhost.localdomain")1478 rv = client.get("/", "http://foo.localhost")1479 # Werkzeug 0.81480 assert rv.status_code == 4041481 except ValueError as e:1482 # Werkzeug 0.71483 assert str(e) == (1484 "the server name provided "detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1485–1486why, one step back1485 "('localhost.localdomain') does not match the "1486 "server name from the WSGI environment ('foo.localhost')"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1487–1492why, one step back1487 )14881489 rv = client.get("/", "http://foo.localhost.localdomain")1490 assert rv.data == b"Foo SubDomain"14911492detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1493–1494why, one step back1493def test_exception_propagation(app, client):1494 def apprunner(config_key):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1495–1498why, one step back1495 @app.route("/")1496 def index():1497 1 // 01498detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1499–1501why, one step back1499 if config_key is not None:1500 app.config[config_key] = True1501 with pytest.raises(Exception):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1502–1505why, one step back1502 client.get("/")1503 else:1504 assert client.get("/").status_code == 5001505detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1506–1509why, one step back1506 # we have to run this test in an isolated thread because if the1507 # debug flag is set to true and an exception happens the context is1508 # not torn down. This causes other tests that run after this fail1509 # when they expect no exception on the stack.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1510why, one step back1510 for config_key in "TESTING", "PROPAGATE_EXCEPTIONS", "DEBUG", None:detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1511–1513why, one step back1511 t = Thread(target=apprunner, args=(config_key,))1512 t.start()1513 t.join()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1514–1530why, one step back151415151516@pytest.mark.parametrize("debug", [True, False])1517@pytest.mark.parametrize("use_debugger", [True, False])1518@pytest.mark.parametrize("use_reloader", [True, False])1519@pytest.mark.parametrize("propagate_exceptions", [None, True, False])1520def test_werkzeug_passthrough_errors(1521 monkeypatch, debug, use_debugger, use_reloader, propagate_exceptions, app1522):1523 rv = {}15241525 # Mocks werkzeug.serving.run_simple method1526 def run_simple_mock(*args, **kwargs):1527 rv["passthrough_errors"] = kwargs.get("passthrough_errors")15281529 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)1530 app.config["PROPAGATE_EXCEPTIONS"] = propagate_exceptionsdetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1531why, one step back1531 app.run(debug=debug, use_debugger=use_debugger, use_reloader=use_reloader)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1532–1533why, one step back15321533detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1534why, one step back1534def test_max_content_length(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1535–1537why, one step back1535 app.config["MAX_CONTENT_LENGTH"] = 6415361537 @app.before_requestdetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1538why, one step back1538 def always_first():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1539–1542why, one step back1539 flask.request.form["myfile"]1540 assert False15411542 @app.route("/accept", methods=["POST"])detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1543why, one step back1543 def accept_file():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1544–1546why, one step back1544 flask.request.form["myfile"]1545 assert False1546detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1547–1548why, one step back1547 @app.errorhandler(413)1548 def catcher(error):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1549–1554why, one step back1549 return "42"15501551 rv = client.post("/accept", data={"myfile": "foo" * 100})1552 assert rv.data == b"42"15531554detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1555–1557why, one step back1555def test_url_processors(app, client):1556 @app.url_defaults1557 def add_language_code(endpoint, values):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1558–1562why, one step back1558 if flask.g.lang_code is not None and app.url_map.is_endpoint_expecting(1559 endpoint, "lang_code"1560 ):1561 values.setdefault("lang_code", flask.g.lang_code)1562detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1563–1564why, one step back1563 @app.url_value_preprocessor1564 def pull_lang_code(endpoint, values):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1565–1571why, one step back1565 flask.g.lang_code = values.pop("lang_code", None)15661567 @app.route("/<lang_code>/")1568 def index():1569 return flask.url_for("about")15701571 @app.route("/<lang_code>/about")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1572why, one step back1572 def about():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1573–1575why, one step back1573 return flask.url_for("something_else")15741575 @app.route("/foo")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1576why, one step back1576 def something_else():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1577–1583why, one step back1577 return flask.url_for("about", lang_code="en")15781579 assert client.get("/de/").data == b"/de/about"1580 assert client.get("/de/about").data == b"/foo"1581 assert client.get("/foo").data == b"/en/about"15821583detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1584why, one step back1584def test_inject_blueprint_url_defaults(app):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1585–1586why, one step back1585 bp = flask.Blueprint("foo.bar.baz", __name__, template_folder="template")1586detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1587–1588why, one step back1587 @bp.url_defaults1588 def bp_defaults(endpoint, values):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1589–1591why, one step back1589 values["page"] = "login"15901591 @bp.route("/<page>")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1592why, one step back1592 def view(page):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1593–1594why, one step back1593 pass1594detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1595why, one step back1595 app.register_blueprint(bp)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1596why, one step back1596detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1597why, one step back1597 values = dict()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1598–1599why, one step back1598 app.inject_url_defaults("foo.bar.baz.view", values)1599 expected = dict(page="login")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1600why, one step back1600 assert values == expectedMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1601–1604why, one step back16011602 with app.test_request_context("/somepage"):1603 url = flask.url_for("foo.bar.baz.view")1604 expected = "/login"detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1605why, one step back1605 assert url == expectedMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1606–1607why, one step back16061607detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1608why, one step back1608def test_nonascii_pathinfo(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1609–1616why, one step back1609 @app.route(u"/киртест")1610 def index():1611 return "Hello World!"16121613 rv = client.get(u"/киртест")1614 assert rv.data == b"Hello World!"16151616detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1617why, one step back1617def test_debug_mode_complains_after_first_request(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1618–1623why, one step back1618 app.debug = True16191620 @app.route("/")1621 def index():1622 return "Awesome"1623detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1624why, one step back1624 assert not app.got_first_requestMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1625why, one step back1625 assert client.get("/").data == b"Awesome"detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1626why, one step back1626 with pytest.raises(AssertionError) as e:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1627–1628why, one step back16271628 @app.route("/foo")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1629why, one step back1629 def broken():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1630–1636why, one step back1630 return "Meh"16311632 assert "A setup function was called" in str(e)16331634 app.debug = False16351636 @app.route("/foo")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1637why, one step back1637 def working():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1638–1643why, one step back1638 return "Meh"16391640 assert client.get("/foo").data == b"Meh"1641 assert app.got_first_request16421643detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1644why, one step back1644def test_before_first_request_functions(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1645–1657why, one step back1645 got = []16461647 @app.before_first_request1648 def foo():1649 got.append(42)16501651 client.get("/")1652 assert got == [42]1653 client.get("/")1654 assert got == [42]1655 assert app.got_first_request16561657detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1658why, one step back1658def test_before_first_request_functions_concurrent(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1659–1662why, one step back1659 got = []16601661 @app.before_first_request1662 def foo():detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1663why, one step back1663 time.sleep(0.2)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1664–1665why, one step back1664 got.append(42)1665detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1666why, one step back1666 def get_and_assert():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1667why, one step back1667 client.get("/")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1668why, one step back1668 assert got == [42]Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1669why, one step back1669detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1670–1673why, one step back1670 t = Thread(target=get_and_assert)1671 t.start()1672 get_and_assert()1673 t.join()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1674–1676why, one step back1674 assert app.got_first_request16751676detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1677why, one step back1677def test_routing_redirect_debugging(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1678–1684why, one step back1678 app.debug = True16791680 @app.route("/foo/", methods=["GET", "POST"])1681 def foo():1682 return "success"16831684 with client:detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1685why, one step back1685 with pytest.raises(AssertionError) as e:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1686–1698why, one step back1686 client.post("/foo", data={})1687 assert "http://localhost/foo/" in str(e)1688 assert ("Make sure to directly send " "your POST-request to this URL") in str(e)16891690 rv = client.get("/foo", data={}, follow_redirects=True)1691 assert rv.data == b"success"16921693 app.debug = False1694 with client:1695 rv = client.post("/foo", data={}, follow_redirects=True)1696 assert rv.data == b"success"16971698detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1699why, one step back1699def test_route_decorator_custom_endpoint(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1700–1706why, one step back1700 app.debug = True17011702 @app.route("/foo/")1703 def foo():1704 return flask.request.endpoint17051706 @app.route("/bar/", endpoint="bar")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1707why, one step back1707 def for_bar():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1708–1710why, one step back1708 return flask.request.endpoint17091710 @app.route("/bar/123", endpoint="123")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1711why, one step back1711 def for_bar_foo():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1712–1723why, one step back1712 return flask.request.endpoint17131714 with app.test_request_context():1715 assert flask.url_for("foo") == "/foo/"1716 assert flask.url_for("bar") == "/bar/"1717 assert flask.url_for("123") == "/bar/123"17181719 assert client.get("/foo/").data == b"foo"1720 assert client.get("/bar/").data == b"bar"1721 assert client.get("/bar/123").data == b"123"17221723detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1724why, one step back1724def test_preserve_only_once(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1725–1730why, one step back1725 app.debug = True17261727 @app.route("/fail")1728 def fail_func():1729 1 // 01730detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1731–1732why, one step back1731 for x in range(3):1732 with pytest.raises(ZeroDivisionError):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1733–1734why, one step back1733 client.get("/fail")1734detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1735–1740why, one step back1735 assert flask._request_ctx_stack.top is not None1736 assert flask._app_ctx_stack.top is not None1737 # implicit appctx disappears too1738 flask._request_ctx_stack.top.pop()1739 assert flask._request_ctx_stack.top is None1740 assert flask._app_ctx_stack.top is NoneMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1741–1742why, one step back17411742detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1743why, one step back1743def test_preserve_remembers_exception(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1744why, one step back1744 app.debug = Truedetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1745why, one step back1745 errors = []Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1746–1751why, one step back17461747 @app.route("/fail")1748 def fail_func():1749 1 // 017501751 @app.route("/success")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1752why, one step back1752 def success_func():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1753–1755why, one step back1753 return "Okay"17541755 @app.teardown_requestdetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1756–1757why, one step back1756 def teardown_handler(exc):1757 errors.append(exc)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1758why, one step back1758detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1759–1760why, one step back1759 # After this failure we did not yet call the teardown handler1760 with pytest.raises(ZeroDivisionError):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1761why, one step back1761 client.get("/fail")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1762why, one step back1762 assert errors == []Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1763why, one step back1763detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1764why, one step back1764 # But this request triggers it, and it's an errorMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1765why, one step back1765 client.get("/success")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1766–1767why, one step back1766 assert len(errors) == 21767 assert isinstance(errors[0], ZeroDivisionError)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1768why, one step back1768detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1769why, one step back1769 # At this point another request does nothing.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1770why, one step back1770 client.get("/success")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1771–1772why, one step back1771 assert len(errors) == 31772 assert errors[1] is NoneMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1773–1774why, one step back17731774detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1775why, one step back1775def test_get_method_on_g(app_ctx):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1776–1777why, one step back1776 assert flask.g.get("x") is None1777 assert flask.g.get("x", 11) == 11detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1778why, one step back1778 flask.g.x = 42Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1779why, one step back1779 assert flask.g.get("x") == 42detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1780why, one step back1780 assert flask.g.x == 42Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1781–1782why, one step back17811782detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1783–1785why, one step back1783def test_g_iteration_protocol(app_ctx):1784 flask.g.foo = 231785 flask.g.bar = 42Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1786–1790why, one step back1786 assert "foo" in flask.g1787 assert "foos" not in flask.g1788 assert sorted(flask.g) == ["bar", "foo"]17891790Merge pull request #2635 from pallets/feature/server-name-routingDavid Lordbefore adoptionf808c20
line 1791why, one step back1791def test_subdomain_basic_support():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1792–1796why, one step back1792 app = flask.Flask(__name__, subdomain_matching=True)1793 app.config["SERVER_NAME"] = "localhost.localdomain"1794 client = app.test_client()17951796 @app.route("/")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1797why, one step back1797 def normal_index():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1798–1800why, one step back1798 return "normal index"17991800 @app.route("/", subdomain="test")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1801why, one step back1801 def test_index():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1802–1810why, one step back1802 return "test index"18031804 rv = client.get("/", "http://localhost.localdomain/")1805 assert rv.data == b"normal index"18061807 rv = client.get("/", "http://test.localhost.localdomain/")1808 assert rv.data == b"test index"18091810Merge pull request #2635 from pallets/feature/server-name-routingDavid Lordbefore adoptionf808c20
line 1811why, one step back1811def test_subdomain_matching():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1812–1823why, one step back1812 app = flask.Flask(__name__, subdomain_matching=True)1813 client = app.test_client()1814 app.config["SERVER_NAME"] = "localhost.localdomain"18151816 @app.route("/", subdomain="<user>")1817 def index(user):1818 return "index for %s" % user18191820 rv = client.get("/", "http://mitsuhiko.localhost.localdomain/")1821 assert rv.data == b"index for mitsuhiko"18221823Merge pull request #2635 from pallets/feature/server-name-routingDavid Lordbefore adoptionf808c20
line 1824why, one step back1824def test_subdomain_matching_with_ports():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1825–1837why, one step back1825 app = flask.Flask(__name__, subdomain_matching=True)1826 app.config["SERVER_NAME"] = "localhost.localdomain:3000"1827 client = app.test_client()18281829 @app.route("/", subdomain="<user>")1830 def index(user):1831 return "index for %s" % user18321833 rv = client.get("/", "http://mitsuhiko.localhost.localdomain:3000/")1834 assert rv.data == b"index for mitsuhiko"183518361837@pytest.mark.parametrize("matching", (False, True))Merge pull request #2635 from pallets/feature/server-name-routingDavid Lordbefore adoptionf808c20
lines 1838–1839why, one step back1838def test_subdomain_matching_other_name(matching):1839 app = flask.Flask(__name__, subdomain_matching=matching)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1840–1846why, one step back1840 app.config["SERVER_NAME"] = "localhost.localdomain:3000"1841 client = app.test_client()18421843 @app.route("/")1844 def index():1845 return "", 2041846Merge pull request #2635 from pallets/feature/server-name-routingDavid Lordbefore adoptionf808c20
line 1847why, one step back1847 # ip address can't match nameMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1848–1850why, one step back1848 rv = client.get("/", "http://127.0.0.1:3000/")1849 assert rv.status_code == 404 if matching else 2041850Merge pull request #2635 from pallets/feature/server-name-routingDavid Lordbefore adoptionf808c20
line 1851why, one step back1851 # allow all subdomains if matching is disabledMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1852–1855why, one step back1852 rv = client.get("/", "http://www.localhost.localdomain:3000/")1853 assert rv.status_code == 404 if matching else 20418541855detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1856why, one step back1856def test_multi_route_rules(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1857–1859why, one step back1857 @app.route("/")1858 @app.route("/<test>/")1859 def index(test="a"):detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1860why, one step back1860 return testMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1861–1867why, one step back18611862 rv = client.open("/")1863 assert rv.data == b"a"1864 rv = client.open("/b/")1865 assert rv.data == b"b"18661867detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1868–1870why, one step back1868def test_multi_route_class_views(app, client):1869 class View(object):1870 def __init__(self, app):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1871–1874why, one step back1871 app.add_url_rule("/", "index", self.index)1872 app.add_url_rule("/<test>/", "index", self.index)18731874 def index(self, test="a"):detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1875why, one step back1875 return testMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1876why, one step back1876detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1877why, one step back1877 _ = View(app)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1878–1883why, one step back1878 rv = client.open("/")1879 assert rv.data == b"a"1880 rv = client.open("/b/")1881 assert rv.data == b"b"18821883detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1884why, one step back1884def test_run_defaults(monkeypatch, app):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1885–1891why, one step back1885 rv = {}18861887 # Mocks werkzeug.serving.run_simple method1888 def run_simple_mock(*args, **kwargs):1889 rv["result"] = "running..."18901891 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1892why, one step back1892 app.run()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1893–1895why, one step back1893 assert rv["result"] == "running..."18941895detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1896why, one step back1896def test_run_server_port(monkeypatch, app):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1897–1899why, one step back1897 rv = {}18981899 # Mocks werkzeug.serving.run_simple methoddetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1900why, one step back1900 def run_simple_mock(hostname, port, application, *args, **kwargs):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1901–1904why, one step back1901 rv["result"] = "running on %s:%s ..." % (hostname, port)19021903 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)1904 hostname, port = "localhost", 8000detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1905why, one step back1905 app.run(hostname, port, debug=True)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1906–1917why, one step back1906 assert rv["result"] == "running on %s:%s ..." % (hostname, port)190719081909@pytest.mark.parametrize(1910 "host,port,expect_host,expect_port",1911 (1912 (None, None, "pocoo.org", 8080),1913 ("localhost", None, "localhost", 8080),1914 (None, 80, "pocoo.org", 80),1915 ("localhost", 80, "localhost", 80),1916 ),1917)detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1918–1921why, one step back1918def test_run_from_config(monkeypatch, host, port, expect_host, expect_port, app):1919 def run_simple_mock(hostname, port, *args, **kwargs):1920 assert hostname == expect_host1921 assert port == expect_portMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1922–1924why, one step back19221923 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)1924 app.config["SERVER_NAME"] = "pocoo.org:8080"detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1925why, one step back1925 app.run(host, port)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1926–1927why, one step back19261927Merge pull request #2693 from davidism/max-cookie-sizeDavid Lordbefore adoptiond8bf589
line 1928why, one step back1928def test_max_cookie_size(app, client, recwarn):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1929–1930why, one step back1929 app.config["MAX_COOKIE_SIZE"] = 1001930Merge pull request #2693 from davidism/max-cookie-sizeDavid Lordbefore adoptiond8bf589
lines 1931–1933why, one step back1931 # outside app context, default to Werkzeug static value,1932 # which is also the default config1933 response = flask.Response()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1934why, one step back1934 default = flask.Flask.default_config["MAX_COOKIE_SIZE"]Merge pull request #2693 from davidism/max-cookie-sizeDavid Lordbefore adoptiond8bf589
line 1935why, one step back1935 assert response.max_cookie_size == defaultMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1936why, one step back1936Merge pull request #2693 from davidism/max-cookie-sizeDavid Lordbefore adoptiond8bf589
lines 1937–1939why, one step back1937 # inside app context, use app config1938 with app.app_context():1939 assert flask.Response().max_cookie_size == 100Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1940–1944why, one step back19401941 @app.route("/")1942 def index():1943 r = flask.Response("", status=204)1944 r.set_cookie("foo", "bar" * 100)Merge pull request #2693 from davidism/max-cookie-sizeDavid Lordbefore adoptiond8bf589
line 1945why, one step back1945 return rMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1946–1947why, one step back19461947 client.get("/")Merge pull request #2693 from davidism/max-cookie-sizeDavid Lordbefore adoptiond8bf589
lines 1948–1949why, one step back1948 assert len(recwarn) == 11949 w = recwarn.pop()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1950–1954why, one step back1950 assert "cookie is too large" in str(w.message)19511952 app.config["MAX_COOKIE_SIZE"] = 019531954 client.get("/")Merge pull request #2693 from davidism/max-cookie-sizeDavid Lordbefore adoptiond8bf589
line 1955why, one step back1955 assert len(recwarn) == 0