test_basic.py
This file
Path
tests/test_basic.py
1,967 lines · 53.0 KiB · Python
Last changed by
Merge pull request #2928 from vorelq/2926-default-port-overrides-zeroDavid Lordbefore adoptiond9fa28b
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–12why, one step back9 :license: BSD, see LICENSE for more details.10"""1112import reMerge pull request #3195 from eruvanos/json_support_dataclassDavid Lordbefore adoptionb0185a6
line 13why, one step back13import sysdetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 14–29why, one step back14import time15import uuid16from datetime import datetime17from threading import Thread1819import pytest20import werkzeug.serving21from werkzeug.exceptions import BadRequest, Forbidden, NotFound22from werkzeug.http import parse_date23from werkzeug.routing import BuildError2425import flask26from flask._compat import text_type272829def test_options_work(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 30–38why, one step back30 @app.route("/", methods=["GET", "POST"])31 def index():32 return "Hello World"3334 rv = client.open("/", method="OPTIONS")35 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS", "POST"]36 assert rv.data == b""3738detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 39why, one step back39def test_options_on_multiple_rules(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 40–44why, one step back40 @app.route("/", methods=["GET", "POST"])41 def index():42 return "Hello World"4344 @app.route("/", methods=["PUT"])detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 45why, one step back45 def index_put():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 46–51why, one step back46 return "Aha!"4748 rv = client.open("/", method="OPTIONS")49 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS", "POST", "PUT"]5051detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 52why, one step back52def test_provide_automatic_options_attr():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 53–57why, one step back53 app = flask.Flask(__name__)5455 def index():56 return "Hello World!"57detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 58why, one step back58 index.provide_automatic_options = FalseMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 59–67why, one step back59 app.route("/")(index)60 rv = app.test_client().open("/", method="OPTIONS")61 assert rv.status_code == 4056263 app = flask.Flask(__name__)6465 def index2():66 return "Hello World!"67detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 68why, one step back68 index2.provide_automatic_options = TrueMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 69–73why, one step back69 app.route("/", methods=["OPTIONS"])(index2)70 rv = app.test_client().open("/", method="OPTIONS")71 assert sorted(rv.allow) == ["OPTIONS"]7273detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 74why, one step back74def test_provide_automatic_options_kwarg(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 75–81why, one step back75 def index():76 return flask.request.method7778 def more():79 return flask.request.method8081 app.add_url_rule("/", view_func=index, provide_automatic_options=False)detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 82why, one step back82 app.add_url_rule(Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 83–93why, one step back83 "/more",84 view_func=more,85 methods=["GET", "POST"],86 provide_automatic_options=False,87 )88 assert client.get("/").data == b"GET"8990 rv = client.post("/")91 assert rv.status_code == 40592 assert sorted(rv.allow) == ["GET", "HEAD"]93detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 94why, one step back94 # Older versions of Werkzeug.test.Client don't have an options methodMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 95–119why, one step back95 if hasattr(client, "options"):96 rv = client.options("/")97 else:98 rv = client.open("/", method="OPTIONS")99100 assert rv.status_code == 405101102 rv = client.head("/")103 assert rv.status_code == 200104 assert not rv.data # head truncates105 assert client.post("/more").data == b"POST"106 assert client.get("/more").data == b"GET"107108 rv = client.delete("/more")109 assert rv.status_code == 405110 assert sorted(rv.allow) == ["GET", "HEAD", "POST"]111112 if hasattr(client, "options"):113 rv = client.options("/more")114 else:115 rv = client.open("/more", method="OPTIONS")116117 assert rv.status_code == 405118119detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 120why, one step back120def test_request_dispatching(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 121–142why, one step back121 @app.route("/")122 def index():123 return flask.request.method124125 @app.route("/more", methods=["GET", "POST"])126 def more():127 return flask.request.method128129 assert client.get("/").data == b"GET"130 rv = client.post("/")131 assert rv.status_code == 405132 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS"]133 rv = client.head("/")134 assert rv.status_code == 200135 assert not rv.data # head truncates136 assert client.post("/more").data == b"POST"137 assert client.get("/more").data == b"GET"138 rv = client.delete("/more")139 assert rv.status_code == 405140 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS", "POST"]141142detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 143–144why, one step back143def test_disallow_string_for_allowed_methods(app):144 with pytest.raises(TypeError):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 145–147why, one step back145146 @app.route("/", methods="GET POST")147 def index():detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 148why, one step back148 return "Hey"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 149–150why, one step back149150detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 151–152why, one step back151def test_url_mapping(app, client):152 random_uuid4 = "7eb41166-9ebf-4d26-b771-ea3f54f8b383"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 153–159why, one step back153154 def index():155 return flask.request.method156157 def more():158 return flask.request.method159detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 160–161why, one step back160 def options():161 return random_uuid4Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 162–165why, one step back162163 app.add_url_rule("/", "index", index)164 app.add_url_rule("/more", "more", more, methods=["GET", "POST"])165detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 166why, one step back166 # 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 167–182why, one step back167 app.add_url_rule("/options", "options", options, methods=["options"])168169 assert client.get("/").data == b"GET"170 rv = client.post("/")171 assert rv.status_code == 405172 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS"]173 rv = client.head("/")174 assert rv.status_code == 200175 assert not rv.data # head truncates176 assert client.post("/more").data == b"POST"177 assert client.get("/more").data == b"GET"178 rv = client.delete("/more")179 assert rv.status_code == 405180 assert sorted(rv.allow) == ["GET", "HEAD", "OPTIONS", "POST"]181 rv = client.open("/options", method="OPTIONS")182 assert rv.status_code == 200detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 183why, one step back183 assert random_uuid4 in rv.data.decode("utf-8")Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 184–185why, one step back184185detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 186why, one step back186def test_werkzeug_routing(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 187–205why, one step back187 from werkzeug.routing import Submount, Rule188189 app.url_map.add(190 Submount("/foo", [Rule("/bar", endpoint="bar"), Rule("/", endpoint="index")])191 )192193 def bar():194 return "bar"195196 def index():197 return "index"198199 app.view_functions["bar"] = bar200 app.view_functions["index"] = index201202 assert client.get("/foo/").data == b"index"203 assert client.get("/foo/bar").data == b"bar"204205detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 206why, one step back206def test_endpoint_decorator(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 207–224why, one step back207 from werkzeug.routing import Submount, Rule208209 app.url_map.add(210 Submount("/foo", [Rule("/bar", endpoint="bar"), Rule("/", endpoint="index")])211 )212213 @app.endpoint("bar")214 def bar():215 return "bar"216217 @app.endpoint("index")218 def index():219 return "index"220221 assert client.get("/foo/").data == b"index"222 assert client.get("/foo/bar").data == b"bar"223224detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 225why, one step back225def test_session(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 226why, one step back226 @app.route("/set", methods=["POST"])detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 227why, one step back227 def set():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 228–231why, one step back228 assert not flask.session.accessed229 assert not flask.session.modified230 flask.session["value"] = flask.request.form["value"]231 assert flask.session.accessedMerge pull request #2580 from pallets/session-attrsDavid Lordbefore adoption26f413e
line 232why, one step back232 assert flask.session.modifiedMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 233–241why, one step back233 return "value set"234235 @app.route("/get")236 def get():237 assert not flask.session.accessed238 assert not flask.session.modified239 v = flask.session.get("value", "None")240 assert flask.session.accessed241 assert not flask.session.modifiedMerge pull request #2580 from pallets/session-attrsDavid Lordbefore adoption26f413e
line 242why, one step back242 return vMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 243–247why, one step back243244 assert client.post("/set", data={"value": "42"}).data == b"value set"245 assert client.get("/get").data == b"42"246247detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 248why, one step back248def test_session_using_server_name(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 249–260why, one step back249 app.config.update(SERVER_NAME="example.com")250251 @app.route("/")252 def index():253 flask.session["testing"] = 42254 return "Hello World"255256 rv = client.get("/", "http://example.com/")257 assert "domain=.example.com" in rv.headers["set-cookie"].lower()258 assert "httponly" in rv.headers["set-cookie"].lower()259260detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 261why, one step back261def test_session_using_server_name_and_port(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 262–273why, one step back262 app.config.update(SERVER_NAME="example.com:8080")263264 @app.route("/")265 def index():266 flask.session["testing"] = 42267 return "Hello World"268269 rv = client.get("/", "http://example.com:8080/")270 assert "domain=.example.com" in rv.headers["set-cookie"].lower()271 assert "httponly" in rv.headers["set-cookie"].lower()272273detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 274why, one step back274def test_session_using_server_name_port_and_path(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 275–287why, one step back275 app.config.update(SERVER_NAME="example.com:8080", APPLICATION_ROOT="/foo")276277 @app.route("/")278 def index():279 flask.session["testing"] = 42280 return "Hello World"281282 rv = client.get("/", "http://example.com:8080/foo")283 assert "domain=example.com" in rv.headers["set-cookie"].lower()284 assert "path=/foo" in rv.headers["set-cookie"].lower()285 assert "httponly" in rv.headers["set-cookie"].lower()286287detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 288–292why, one step back288def test_session_using_application_root(app, client):289 class PrefixPathMiddleware(object):290 def __init__(self, app, prefix):291 self.app = app292 self.prefix = prefixMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 293why, one step back293detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 294why, one step back294 def __call__(self, environ, start_response):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 295why, one step back295 environ["SCRIPT_NAME"] = self.prefixdetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 296why, one step back296 return self.app(environ, start_response)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 297–309why, one step back297298 app.wsgi_app = PrefixPathMiddleware(app.wsgi_app, "/bar")299 app.config.update(APPLICATION_ROOT="/bar")300301 @app.route("/")302 def index():303 flask.session["testing"] = 42304 return "Hello World"305306 rv = client.get("/", "http://example.com:8080/")307 assert "path=/bar" in rv.headers["set-cookie"].lower()308309detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 310why, one step back310def test_session_using_session_settings(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 311–314why, one step back311 app.config.update(312 SERVER_NAME="www.example.com:8080",313 APPLICATION_ROOT="/test",314 SESSION_COOKIE_DOMAIN=".example.com",detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 315–316why, one step back315 SESSION_COOKIE_HTTPONLY=False,316 SESSION_COOKIE_SECURE=True,Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 317–334why, one step back317 SESSION_COOKIE_SAMESITE="Lax",318 SESSION_COOKIE_PATH="/",319 )320321 @app.route("/")322 def index():323 flask.session["testing"] = 42324 return "Hello World"325326 rv = client.get("/", "http://www.example.com:8080/test/")327 cookie = rv.headers["set-cookie"].lower()328 assert "domain=.example.com" in cookie329 assert "path=/" in cookie330 assert "secure" in cookie331 assert "httponly" not in cookie332 assert "samesite" in cookie333334Merge pull request #2607 from FadhelC/SameSite-cookie-featureDavid Lordbefore adoptione21abd9
line 335why, one step back335def test_session_using_samesite_attribute(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 336–342why, one step back336 @app.route("/")337 def index():338 flask.session["testing"] = 42339 return "Hello World"340341 app.config.update(SESSION_COOKIE_SAMESITE="invalid")342Merge pull request #2607 from FadhelC/SameSite-cookie-featureDavid Lordbefore adoptione21abd9
line 343why, one step back343 with pytest.raises(ValueError):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 344–345why, one step back344 client.get("/")345Merge pull request #2607 from FadhelC/SameSite-cookie-featureDavid Lordbefore adoptione21abd9
line 346why, one step back346 app.config.update(SESSION_COOKIE_SAMESITE=None)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 347–361why, one step back347 rv = client.get("/")348 cookie = rv.headers["set-cookie"].lower()349 assert "samesite" not in cookie350351 app.config.update(SESSION_COOKIE_SAMESITE="Strict")352 rv = client.get("/")353 cookie = rv.headers["set-cookie"].lower()354 assert "samesite=strict" in cookie355356 app.config.update(SESSION_COOKIE_SAMESITE="Lax")357 rv = client.get("/")358 cookie = rv.headers["set-cookie"].lower()359 assert "samesite=lax" in cookie360361detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 362why, one step back362def test_session_localhost_warning(recwarn, app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 363–372why, one step back363 app.config.update(SERVER_NAME="localhost:5000")364365 @app.route("/")366 def index():367 flask.session["testing"] = 42368 return "testing"369370 rv = client.get("/", "http://localhost:5000/")371 assert "domain" not in rv.headers["set-cookie"].lower()372 w = recwarn.pop(UserWarning)detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 373why, one step back373 assert '"localhost" is not a valid cookie domain' in str(w.message)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 374–375why, one step back374375detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 376why, one step back376def test_session_ip_warning(recwarn, app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 377–389why, one step back377 app.config.update(SERVER_NAME="127.0.0.1:5000")378379 @app.route("/")380 def index():381 flask.session["testing"] = 42382 return "testing"383384 rv = client.get("/", "http://127.0.0.1:5000/")385 assert "domain=127.0.0.1" in rv.headers["set-cookie"].lower()386 w = recwarn.pop(UserWarning)387 assert "cookie domain is an IP" in str(w.message)388389detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 390–391why, one step back390def test_missing_session(app):391 app.secret_key = NoneMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 392why, one step back392detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 393–394why, one step back393 def expect_exception(f, *args, **kwargs):394 e = pytest.raises(RuntimeError, f, *args, **kwargs)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 395–402why, one step back395 assert e.value.args and "session is unavailable" in e.value.args[0]396397 with app.test_request_context():398 assert flask.session.get("missing_key") is None399 expect_exception(flask.session.__setitem__, "foo", 42)400 expect_exception(flask.session.pop, "foo")401402detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 403–404why, one step back403def test_session_expiration(app, client):404 permanent = TrueMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 405–408why, one step back405406 @app.route("/")407 def index():408 flask.session["test"] = 42detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 409why, one step back409 flask.session.permanent = permanentMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 410–413why, one step back410 return ""411412 @app.route("/test")413 def test():detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 414why, one step back414 return text_type(flask.session.permanent)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 415–418why, one step back415416 rv = client.get("/")417 assert "set-cookie" in rv.headers418 match = re.search(r"(?i)\bexpires=([^;]+)", rv.headers["set-cookie"])detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 419–423why, one step back419 expires = parse_date(match.group())420 expected = datetime.utcnow() + app.permanent_session_lifetime421 assert expires.year == expected.year422 assert expires.month == expected.month423 assert expires.day == expected.dayMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 424–427why, one step back424425 rv = client.get("/test")426 assert rv.data == b"True"427detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 428why, one step back428 permanent = FalseMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 429–431why, one step back429 rv = client.get("/")430 assert "set-cookie" in rv.headers431 match = re.search(r"\bexpires=([^;]+)", rv.headers["set-cookie"])detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 432why, one step back432 assert match is NoneMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 433–434why, one step back433434detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 435why, one step back435def test_session_stored_last(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 436why, one step back436 @app.after_requestdetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 437why, one step back437 def modify_session(response):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 438–448why, one step back438 flask.session["foo"] = 42439 return response440441 @app.route("/")442 def dump_session_contents():443 return repr(flask.session.get("foo"))444445 assert client.get("/").data == b"None"446 assert client.get("/").data == b"42"447448detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 449–451why, one step back449def test_session_special_types(app, client):450 now = datetime.utcnow().replace(microsecond=0)451 the_uuid = uuid.uuid4()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 452–466why, one step back452453 @app.route("/")454 def dump_session_contents():455 flask.session["t"] = (1, 2, 3)456 flask.session["b"] = b"\xff"457 flask.session["m"] = flask.Markup("<html>")458 flask.session["u"] = the_uuid459 flask.session["d"] = now460 flask.session["t_tag"] = {" t": "not-a-tuple"}461 flask.session["di_t_tag"] = {" t__": "not-a-tuple"}462 flask.session["di_tag"] = {" di": "not-a-dict"}463 return "", 204464465 with client:466 client.get("/")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 467why, one step back467 s = flask.sessionMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 468–479why, one step back468 assert s["t"] == (1, 2, 3)469 assert type(s["b"]) == bytes470 assert s["b"] == b"\xff"471 assert type(s["m"]) == flask.Markup472 assert s["m"] == flask.Markup("<html>")473 assert s["u"] == the_uuid474 assert s["d"] == now475 assert s["t_tag"] == {" t": "not-a-tuple"}476 assert s["di_t_tag"] == {" t__": "not-a-tuple"}477 assert s["di_tag"] == {" di": "not-a-dict"}478479detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 480why, one step back480def test_session_cookie_setting(app):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 481–483why, one step back481 is_permanent = True482483 @app.route("/bump")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 484why, one step back484 def bump():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 485why, one step back485 rv = flask.session["foo"] = flask.session.get("foo", 0) + 1detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 486–487why, one step back486 flask.session.permanent = is_permanent487 return str(rv)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 488–489why, one step back488489 @app.route("/read")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 490why, one step back490 def read():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 491–492why, one step back491 return str(flask.session.get("foo", 0))492detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 493–494why, one step back493 def run_test(expect_header):494 with app.test_client() as c:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 495–500why, one step back495 assert c.get("/bump").data == b"1"496 assert c.get("/bump").data == b"2"497 assert c.get("/bump").data == b"3"498499 rv = c.get("/read")500 set_cookie = rv.headers.get("set-cookie")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 501why, one step back501 assert (set_cookie is not None) == expect_headerMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 502–505why, one step back502 assert rv.data == b"3"503504 is_permanent = True505 app.config["SESSION_REFRESH_EACH_REQUEST"] = Truedetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 506why, one step back506 run_test(expect_header=True)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 507–520why, one step back507508 is_permanent = True509 app.config["SESSION_REFRESH_EACH_REQUEST"] = False510 run_test(expect_header=False)511512 is_permanent = False513 app.config["SESSION_REFRESH_EACH_REQUEST"] = True514 run_test(expect_header=False)515516 is_permanent = False517 app.config["SESSION_REFRESH_EACH_REQUEST"] = False518 run_test(expect_header=False)519520detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 521why, one step back521def test_session_vary_cookie(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 522why, one step back522 @app.route("/set")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 523why, one step back523 def set_session():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 524–531why, one step back524 flask.session["test"] = "test"525 return ""526527 @app.route("/get")528 def get():529 return flask.session.get("test")530531 @app.route("/getitem")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 532why, one step back532 def getitem():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 533–535why, one step back533 return flask.session["test"]534535 @app.route("/setdefault")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 536why, one step back536 def setdefault():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 537–539why, one step back537 return flask.session.setdefault("test", "default")538539 @app.route("/vary-cookie-header-set")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 540why, one step back540 def vary_cookie_header_set():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 541–546why, one step back541 response = flask.Response()542 response.vary.add("Cookie")543 flask.session["test"] = "test"544 return response545546 @app.route("/vary-header-set")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 547why, one step back547 def vary_header_set():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 548–553why, one step back548 response = flask.Response()549 response.vary.update(("Accept-Encoding", "Accept-Language"))550 flask.session["test"] = "test"551 return response552553 @app.route("/no-vary-header")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 554why, one step back554 def no_vary_header():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 555–557why, one step back555 return ""556557 def expect(path, header_value="Cookie"):detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 558why, one step back558 rv = client.get(path)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 559why, one step back559detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 560–561why, one step back560 if header_value:561 # The 'Vary' key should exist in the headers only once.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 562–575why, one step back562 assert len(rv.headers.get_all("Vary")) == 1563 assert rv.headers["Vary"] == header_value564 else:565 assert "Vary" not in rv.headers566567 expect("/set")568 expect("/get")569 expect("/getitem")570 expect("/setdefault")571 expect("/vary-cookie-header-set")572 expect("/vary-header-set", "Accept-Encoding, Accept-Language, Cookie")573 expect("/no-vary-header", None)574575detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 576–577why, one step back576def test_flashes(app, req_ctx):577 assert not flask.session.modifiedMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 578why, one step back578 flask.flash("Zap")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 579why, one step back579 flask.session.modified = FalseMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 580why, one step back580 flask.flash("Zip")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 581why, one step back581 assert flask.session.modifiedMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 582–584why, one step back582 assert list(flask.get_flashed_messages()) == ["Zap", "Zip"]583584detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 585–590why, one step back585def test_extended_flashing(app):586 # Be sure app.testing=True below, else tests can fail silently.587 #588 # Specifically, if app.testing is not set to True, the AssertionErrors589 # in the view functions will cause a 500 response to the test client590 # instead of propagating exceptions.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 591–600why, one step back591592 @app.route("/")593 def index():594 flask.flash(u"Hello World")595 flask.flash(u"Hello World", "error")596 flask.flash(flask.Markup(u"<em>Testing</em>"), "warning")597 return ""598599 @app.route("/test/")600 def test():detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 601why, one step back601 messages = flask.get_flashed_messages()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 602–609why, one step back602 assert list(messages) == [603 u"Hello World",604 u"Hello World",605 flask.Markup(u"<em>Testing</em>"),606 ]607 return ""608609 @app.route("/test_with_categories/")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 610–612why, one step back610 def test_with_categories():611 messages = flask.get_flashed_messages(with_categories=True)612 assert len(messages) == 3Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 613–620why, one step back613 assert list(messages) == [614 ("message", u"Hello World"),615 ("error", u"Hello World"),616 ("warning", flask.Markup(u"<em>Testing</em>")),617 ]618 return ""619620 @app.route("/test_filter/")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 621why, one step back621 def test_filter():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 622–628why, one step back622 messages = flask.get_flashed_messages(623 category_filter=["message"], with_categories=True624 )625 assert list(messages) == [("message", u"Hello World")]626 return ""627628 @app.route("/test_filters/")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 629why, one step back629 def test_filters():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 630–639why, one step back630 messages = flask.get_flashed_messages(631 category_filter=["message", "warning"], with_categories=True632 )633 assert list(messages) == [634 ("message", u"Hello World"),635 ("warning", flask.Markup(u"<em>Testing</em>")),636 ]637 return ""638639 @app.route("/test_filters_without_returning_categories/")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 640why, one step back640 def test_filters2():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 641why, one step back641 messages = flask.get_flashed_messages(category_filter=["message", "warning"])detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 642why, one step back642 assert len(messages) == 2Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 643–646why, one step back643 assert messages[0] == u"Hello World"644 assert messages[1] == flask.Markup(u"<em>Testing</em>")645 return ""646detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 647why, one step back647 # Create new test client on each test to clean flashed messages.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 648–665why, one step back648649 client = app.test_client()650 client.get("/")651 client.get("/test_with_categories/")652653 client = app.test_client()654 client.get("/")655 client.get("/test_filter/")656657 client = app.test_client()658 client.get("/")659 client.get("/test_filters/")660661 client = app.test_client()662 client.get("/")663 client.get("/test_filters_without_returning_categories/")664665detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 666why, one step back666def test_request_processing(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 667–690why, one step back667 evts = []668669 @app.before_request670 def before_request():671 evts.append("before")672673 @app.after_request674 def after_request(response):675 response.data += b"|after"676 evts.append("after")677 return response678679 @app.route("/")680 def index():681 assert "before" in evts682 assert "after" not in evts683 return "request"684685 assert "after" not in evts686 rv = client.get("/").data687 assert "after" in evts688 assert rv == b"request|after"689690detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 691why, one step back691def test_request_preprocessing_early_return(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 692–694why, one step back692 evts = []693694 @app.before_requestdetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 695–696why, one step back695 def before_request1():696 evts.append(1)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 697–698why, one step back697698 @app.before_requestdetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 699–701why, one step back699 def before_request2():700 evts.append(2)701 return "hello"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 702–703why, one step back702703 @app.before_requestdetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 704–706why, one step back704 def before_request3():705 evts.append(3)706 return "bye"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 707–710why, one step back707708 @app.route("/")709 def index():710 evts.append("index")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 711why, one step back711 return "damnit"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 712–714why, one step back712713 rv = client.get("/").data.strip()714 assert rv == b"hello"detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 715why, one step back715 assert evts == [1, 2]Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 716–717why, one step back716717detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 718why, one step back718def test_after_request_processing(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 719–720why, one step back719 @app.route("/")720 def index():detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 721–722why, one step back721 @flask.after_this_request722 def foo(response):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 723why, one step back723 response.headers["X-Foo"] = "a header"detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 724why, one step back724 return responseMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 725–728why, one step back725726 return "Test"727728 resp = client.get("/")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 729why, one step back729 assert resp.status_code == 200Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 730–732why, one step back730 assert resp.headers["X-Foo"] == "a header"731732detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 733why, one step back733def test_teardown_request_handler(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 734–750why, one step back734 called = []735736 @app.teardown_request737 def teardown_request(exc):738 called.append(True)739 return "Ignored"740741 @app.route("/")742 def root():743 return "Response"744745 rv = client.get("/")746 assert rv.status_code == 200747 assert b"Response" in rv.data748 assert len(called) == 1749750detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 751why, one step back751def test_teardown_request_handler_debug_mode(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 752–768why, one step back752 called = []753754 @app.teardown_request755 def teardown_request(exc):756 called.append(True)757 return "Ignored"758759 @app.route("/")760 def root():761 return "Response"762763 rv = client.get("/")764 assert rv.status_code == 200765 assert b"Response" in rv.data766 assert len(called) == 1767768detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 769why, one step back769def test_teardown_request_handler_error(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 770–773why, one step back770 called = []771 app.testing = False772773 @app.teardown_requestdetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 774why, one step back774 def teardown_request1(exc):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 775–785why, one step back775 assert type(exc) == ZeroDivisionError776 called.append(True)777 # This raises a new error and blows away sys.exc_info(), so we can778 # test that all teardown_requests get passed the same original779 # exception.780 try:781 raise TypeError()782 except:783 pass784785 @app.teardown_requestdetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 786why, one step back786 def teardown_request2(exc):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 787–797why, one step back787 assert type(exc) == ZeroDivisionError788 called.append(True)789 # This raises a new error and blows away sys.exc_info(), so we can790 # test that all teardown_requests get passed the same original791 # exception.792 try:793 raise TypeError()794 except:795 pass796797 @app.route("/")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 798why, one step back798 def fails():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 799–803why, one step back799 1 // 0800801 rv = client.get("/")802 assert rv.status_code == 500803 assert b"Internal Server Error" in rv.datadetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 804why, one step back804 assert len(called) == 2Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 805–806why, one step back805806detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 807why, one step back807def test_before_after_request_order(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 808–810why, one step back808 called = []809810 @app.before_requestdetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 811–812why, one step back811 def before1():812 called.append(1)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 813–814why, one step back813814 @app.before_requestdetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 815–816why, one step back815 def before2():816 called.append(2)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 817–818why, one step back817818 @app.after_requestdetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 819–820why, one step back819 def after1(response):820 called.append(4)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 821–823why, one step back821 return response822823 @app.after_requestdetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 824–825why, one step back824 def after2(response):825 called.append(3)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 826–828why, one step back826 return response827828 @app.teardown_requestdetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 829–830why, one step back829 def finish1(exc):830 called.append(6)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 831–832why, one step back831832 @app.teardown_requestdetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 833–834why, one step back833 def finish2(exc):834 called.append(5)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 835–841why, one step back835836 @app.route("/")837 def index():838 return "42"839840 rv = client.get("/")841 assert rv.data == b"42"detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 842why, one step back842 assert called == [1, 2, 3, 4, 5, 6]Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 843–844why, one step back843844detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 845why, one step back845def test_error_handling(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 846–848why, one step back846 app.testing = False847848 @app.errorhandler(404)detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 849why, one step back849 def not_found(e):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 850–855why, one step back850 return "not found", 404851852 @app.errorhandler(500)853 def internal_server_error(e):854 return "internal server error", 500855detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 856–857why, one step back856 @app.errorhandler(Forbidden)857 def forbidden(e):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 858–864why, one step back858 return "forbidden", 403859860 @app.route("/")861 def index():862 flask.abort(404)863864 @app.route("/error")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 865why, one step back865 def error():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 866–868why, one step back866 1 // 0867868 @app.route("/forbidden")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 869why, one step back869 def error2():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 870–878why, one step back870 flask.abort(403)871872 rv = client.get("/")873 assert rv.status_code == 404874 assert rv.data == b"not found"875 rv = client.get("/error")876 assert rv.status_code == 500877 assert b"internal server error" == rv.data878 rv = client.get("/forbidden")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 879why, one step back879 assert rv.status_code == 403Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 880–882why, one step back880 assert b"forbidden" == rv.data881882detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 883–884why, one step back883def test_error_handler_unknown_code(app):884 with pytest.raises(KeyError) as exc_info:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 885–889why, one step back885 app.register_error_handler(999, lambda e: ("999", 999))886887 assert "Use a subclass" in exc_info.value.args[0]888889detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 890why, one step back890def test_error_handling_processing(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 891–901why, one step back891 app.testing = False892893 @app.errorhandler(500)894 def internal_server_error(e):895 return "internal server error", 500896897 @app.route("/")898 def broken_func():899 1 // 0900901 @app.after_requestdetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 902why, one step back902 def after_request(resp):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 903why, one step back903 resp.mimetype = "text/x-special"detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 904why, one step back904 return respMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 905–910why, one step back905906 resp = client.get("/")907 assert resp.mimetype == "text/x-special"908 assert resp.data == b"internal server error"909910detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 911why, one step back911def test_baseexception_error_handling(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 912–915why, one step back912 app.testing = False913914 @app.route("/")915 def broken_func():detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 916why, one step back916 raise KeyboardInterrupt()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 917why, one step back917detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 918why, one step back918 with pytest.raises(KeyboardInterrupt):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 919–920why, one step back919 client.get("/")920detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 921–923why, one step back921 ctx = flask._request_ctx_stack.top922 assert ctx.preserved923 assert type(ctx._preserved_exc) is KeyboardInterruptMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 924–925why, one step back924925detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 926why, one step back926def test_before_request_and_routing_errors(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 927why, one step back927 @app.before_requestdetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 928why, one step back928 def attach_something():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 929–931why, one step back929 flask.g.something = "value"930931 @app.errorhandler(404)detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 932–933why, one step back932 def return_something(error):933 return flask.g.something, 404Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 934–939why, one step back934935 rv = client.get("/")936 assert rv.status_code == 404937 assert rv.data == b"value"938939detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 940–941why, one step back940def test_user_error_handling(app, client):941 class MyException(Exception):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 942–943why, one step back942 pass943detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 944–946why, one step back944 @app.errorhandler(MyException)945 def handle_my_exception(e):946 assert isinstance(e, MyException)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 947–950why, one step back947 return "42"948949 @app.route("/")950 def index():detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 951why, one step back951 raise MyException()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 952–955why, one step back952953 assert client.get("/").data == b"42"954955detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 956–957why, one step back956def test_http_error_subclass_handling(app, client):957 class ForbiddenSubclass(Forbidden):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 958–959why, one step back958 pass959detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 960why, one step back960 @app.errorhandler(ForbiddenSubclass)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 961why, one step back961 def handle_forbidden_subclass(e):detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 962why, one step back962 assert isinstance(e, ForbiddenSubclass)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 963–964why, one step back963 return "banana"964detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 965why, one step back965 @app.errorhandler(403)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 966why, one step back966 def handle_forbidden_subclass(e):detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 967–968why, one step back967 assert not isinstance(e, ForbiddenSubclass)968 assert isinstance(e, Forbidden)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 969–971why, one step back969 return "apple"970971 @app.route("/1")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 972–973why, one step back972 def index1():973 raise ForbiddenSubclass()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 974–979why, one step back974975 @app.route("/2")976 def index2():977 flask.abort(403)978979 @app.route("/3")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 980–981why, one step back980 def index3():981 raise Forbidden()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 982–987why, one step back982983 assert client.get("/1").data == b"banana"984 assert client.get("/2").data == b"apple"985 assert client.get("/3").data == b"apple"986987detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 988–989why, one step back988def test_errorhandler_precedence(app, client):989 class E1(Exception):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 990–991why, one step back990 pass991detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 992why, one step back992 class E2(Exception):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 993–994why, one step back993 pass994detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 995why, one step back995 class E3(E1, E2):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 996–997why, one step back996 pass997detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 998–999why, one step back998 @app.errorhandler(E2)999 def handle_e2(e):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1000–1001why, one step back1000 return "E2"1001detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1002–1003why, one step back1002 @app.errorhandler(Exception)1003 def handle_exception(e):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1004–1006why, one step back1004 return "Exception"10051006 @app.route("/E1")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1007–1008why, one step back1007 def raise_e1():1008 raise E1Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1009–1010why, one step back10091010 @app.route("/E3")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1011–1012why, one step back1011 def raise_e3():1012 raise E3Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1013–1020why, one step back10131014 rv = client.get("/E1")1015 assert rv.data == b"Exception"10161017 rv = client.get("/E3")1018 assert rv.data == b"E2"10191020detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1021why, one step back1021def test_trapping_of_bad_request_key_errors(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1022–1026why, one step back1022 @app.route("/key")1023 def fail():1024 flask.request.form["missing_key"]10251026 @app.route("/abort")Merge branch '1.0-maintenance'David Lordbefore adoption1fa9185
lines 1027–1028why, one step back1027 def allow_abort():1028 flask.abort(400)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1029–1036why, one step back10291030 rv = client.get("/key")1031 assert rv.status_code == 4001032 assert b"missing_key" not in rv.data1033 rv = client.get("/abort")1034 assert rv.status_code == 40010351036 app.debug = Truedetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1037why, one step back1037 with pytest.raises(KeyError) as e:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1038why, one step back1038 client.get("/key")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1039why, one step back1039 assert e.errisinstance(BadRequest)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1040–1045why, one step back1040 assert "missing_key" in e.value.get_description()1041 rv = client.get("/abort")1042 assert rv.status_code == 40010431044 app.debug = False1045 app.config["TRAP_BAD_REQUEST_ERRORS"] = TrueMerge branch '1.0-maintenance'David Lordbefore adoption1fa9185
line 1046why, one step back1046 with pytest.raises(KeyError):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1047why, one step back1047 client.get("/key")Merge branch '1.0-maintenance'David Lordbefore adoption1fa9185
line 1048why, one step back1048 with pytest.raises(BadRequest):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1049–1051why, one step back1049 client.get("/abort")10501051detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1052why, one step back1052def test_trapping_of_all_http_exceptions(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1053–1058why, one step back1053 app.config["TRAP_HTTP_EXCEPTIONS"] = True10541055 @app.route("/fail")1056 def fail():1057 flask.abort(404)1058detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1059why, one step back1059 with pytest.raises(NotFound):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1060–1062why, one step back1060 client.get("/fail")10611062Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469
line 1063why, one step back1063def test_error_handler_after_processor_error(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1064–1086why, one step back1064 app.testing = False10651066 @app.before_request1067 def before_request():1068 if trigger == "before":1069 1 // 010701071 @app.after_request1072 def after_request(response):1073 if trigger == "after":1074 1 // 01075 return response10761077 @app.route("/")1078 def index():1079 return "Foo"10801081 @app.errorhandler(500)1082 def internal_server_error(e):1083 return "Hello Server Error", 50010841085 for trigger in "before", "after":1086 rv = client.get("/")Merge pull request #2436 from davidism/loggingDavid Lordbefore adoptionc74f469
line 1087why, one step back1087 assert rv.status_code == 500Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1088–1090why, one step back1088 assert rv.data == b"Hello Server Error"10891090detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1091–1092why, one step back1091def test_enctype_debug_helper(app, client):1092 from flask.debughelpers import DebugFilesKeyErrorMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1093–1099why, one step back10931094 app.debug = True10951096 @app.route("/fail", methods=["POST"])1097 def index():1098 return flask.request.files["foo"].filename1099detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1100–1102why, one step back1100 # with statement is important because we leave an exception on the1101 # stack otherwise and we want to ensure that this is not the case1102 # to not negatively affect other tests.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1103why, one step back1103 with client:detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1104why, one step back1104 with pytest.raises(DebugFilesKeyError) as e:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1105–1106why, one step back1105 client.post("/fail", data={"foo": "index.txt"})1106 assert "no file contents were transmitted" in str(e.value)detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1107why, one step back1107 assert 'This was submitted: "index.txt"' in str(e.value)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1108–1109why, one step back11081109detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1110why, one step back1110def test_response_types(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1111why, one step back1111 @app.route("/text")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1112why, one step back1112 def from_text():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1113–1115why, one step back1113 return u"Hällo Wörld"11141115 @app.route("/bytes")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1116why, one step back1116 def from_bytes():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1117–1119why, one step back1117 return u"Hällo Wörld".encode("utf-8")11181119 @app.route("/full_tuple")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1120why, one step back1120 def from_full_tuple():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1121–1127why, one step back1121 return (1122 "Meh",1123 400,1124 {"X-Foo": "Testing", "Content-Type": "text/plain; charset=utf-8"},1125 )11261127 @app.route("/text_headers")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1128why, one step back1128 def from_text_headers():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1129–1131why, one step back1129 return "Hello", {"X-Foo": "Test", "Content-Type": "text/plain; charset=utf-8"}11301131 @app.route("/text_status")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1132why, one step back1132 def from_text_status():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1133–1135why, one step back1133 return "Hi, status!", 40011341135 @app.route("/response_headers")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1136why, one step back1136 def from_response_headers():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1137–1142why, one step back1137 return (1138 flask.Response("Hello world", 404, {"X-Foo": "Baz"}),1139 {"X-Foo": "Bar", "X-Bar": "Foo"},1140 )11411142 @app.route("/response_status")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1143why, one step back1143 def from_response_status():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1144–1146why, one step back1144 return app.response_class("Hello world", 400), 50011451146 @app.route("/wsgi")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1147–1148why, one step back1147 def from_wsgi():1148 return NotFound()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1149–1184why, one step back11491150 assert client.get("/text").data == u"Hällo Wörld".encode("utf-8")1151 assert client.get("/bytes").data == u"Hällo Wörld".encode("utf-8")11521153 rv = client.get("/full_tuple")1154 assert rv.data == b"Meh"1155 assert rv.headers["X-Foo"] == "Testing"1156 assert rv.status_code == 4001157 assert rv.mimetype == "text/plain"11581159 rv = client.get("/text_headers")1160 assert rv.data == b"Hello"1161 assert rv.headers["X-Foo"] == "Test"1162 assert rv.status_code == 2001163 assert rv.mimetype == "text/plain"11641165 rv = client.get("/text_status")1166 assert rv.data == b"Hi, status!"1167 assert rv.status_code == 4001168 assert rv.mimetype == "text/html"11691170 rv = client.get("/response_headers")1171 assert rv.data == b"Hello world"1172 assert rv.headers.getlist("X-Foo") == ["Baz", "Bar"]1173 assert rv.headers["X-Bar"] == "Foo"1174 assert rv.status_code == 40411751176 rv = client.get("/response_status")1177 assert rv.data == b"Hello world"1178 assert rv.status_code == 50011791180 rv = client.get("/wsgi")1181 assert b"Not Found" in rv.data1182 assert rv.status_code == 40411831184detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1185why, one step back1185def test_response_type_errors():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1186–1189why, one step back1186 app = flask.Flask(__name__)1187 app.testing = True11881189 @app.route("/none")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1190why, one step back1190 def from_none():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1191–1193why, one step back1191 pass11921193 @app.route("/small_tuple")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1194why, one step back1194 def from_small_tuple():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1195–1197why, one step back1195 return ("Hello",)11961197 @app.route("/large_tuple")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1198why, one step back1198 def from_large_tuple():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1199–1201why, one step back1199 return "Hello", 234, {"X-Foo": "Bar"}, "???"12001201 @app.route("/bad_type")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1202–1203why, one step back1202 def from_bad_type():1203 return TrueMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1204–1205why, one step back12041205 @app.route("/bad_wsgi")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1206–1207why, one step back1206 def from_bad_wsgi():1207 return lambda: NoneMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1208–1227why, one step back12081209 c = app.test_client()12101211 with pytest.raises(TypeError) as e:1212 c.get("/none")1213 assert "returned None" in str(e)12141215 with pytest.raises(TypeError) as e:1216 c.get("/small_tuple")1217 assert "tuple must have the form" in str(e)12181219 pytest.raises(TypeError, c.get, "/large_tuple")12201221 with pytest.raises(TypeError) as e:1222 c.get("/bad_type")1223 assert "it was a bool" in str(e)12241225 pytest.raises(TypeError, c.get, "/bad_wsgi")12261227detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1228–1229why, one step back1228def test_make_response(app, req_ctx):1229 rv = flask.make_response()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1230–1244why, one step back1230 assert rv.status_code == 2001231 assert rv.data == b""1232 assert rv.mimetype == "text/html"12331234 rv = flask.make_response("Awesome")1235 assert rv.status_code == 2001236 assert rv.data == b"Awesome"1237 assert rv.mimetype == "text/html"12381239 rv = flask.make_response("W00t", 404)1240 assert rv.status_code == 4041241 assert rv.data == b"W00t"1242 assert rv.mimetype == "text/html"12431244detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1245why, one step back1245def test_make_response_with_response_instance(app, req_ctx):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1246–1247why, one step back1246 rv = flask.make_response(flask.jsonify({"msg": "W00t"}), 400)1247 assert rv.status_code == 400detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1248why, one step back1248 assert rv.data == b'{"msg":"W00t"}\n'Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1249–1265why, one step back1249 assert rv.mimetype == "application/json"12501251 rv = flask.make_response(flask.Response(""), 400)1252 assert rv.status_code == 4001253 assert rv.data == b""1254 assert rv.mimetype == "text/html"12551256 rv = flask.make_response(1257 flask.Response("", headers={"Content-Type": "text/html"}),1258 400,1259 [("X-Foo", "bar")],1260 )1261 assert rv.status_code == 4001262 assert rv.headers["Content-Type"] == "text/html"1263 assert rv.headers["X-Foo"] == "bar"12641265detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1266–1268why, one step back1266def test_jsonify_no_prettyprint(app, req_ctx):1267 app.config.update({"JSONIFY_PRETTYPRINT_REGULAR": False})1268 compressed_msg = b'{"msg":{"submsg":"W00t"},"msg2":"foobar"}\n'Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1269–1271why, one step back1269 uncompressed_msg = {"msg": {"submsg": "W00t"}, "msg2": "foobar"}12701271 rv = flask.make_response(flask.jsonify(uncompressed_msg), 200)detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1272why, one step back1272 assert rv.data == compressed_msgMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1273–1274why, one step back12731274detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1275–1277why, one step back1275def test_jsonify_prettyprint(app, req_ctx):1276 app.config.update({"JSONIFY_PRETTYPRINT_REGULAR": True})1277 compressed_msg = {"msg": {"submsg": "W00t"}, "msg2": "foobar"}Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1278why, one step back1278 pretty_response = (detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1279why, one step back1279 b'{\n "msg": {\n "submsg": "W00t"\n }, \n "msg2": "foobar"\n}\n'Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1280–1282why, one step back1280 )12811282 rv = flask.make_response(flask.jsonify(compressed_msg), 200)detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1283why, one step back1283 assert rv.data == pretty_responseMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1284–1285why, one step back12841285detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1286why, one step back1286def test_jsonify_mimetype(app, req_ctx):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1287–1291why, one step back1287 app.config.update({"JSONIFY_MIMETYPE": "application/vnd.api+json"})1288 msg = {"msg": {"submsg": "W00t"}}1289 rv = flask.make_response(flask.jsonify(msg), 200)1290 assert rv.mimetype == "application/vnd.api+json"1291Merge pull request #3195 from eruvanos/json_support_dataclassDavid Lordbefore adoptionb0185a6
lines 1292–1299why, one step back12921293@pytest.mark.skipif(sys.version_info < (3, 7), reason="requires Python >= 3.7")1294def test_json_dump_dataclass(app, req_ctx):1295 from dataclasses import make_dataclass1296 Data = make_dataclass("Data", [("name", str)])1297 value = flask.json.dumps(Data("Flask"), app=app)1298 value = flask.json.loads(value, app=app)1299 assert value == {"name": "Flask"}Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1300why, one step back1300detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1301why, one step back1301def test_jsonify_args_and_kwargs_check(app, req_ctx):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1302–1306why, one step back1302 with pytest.raises(TypeError) as e:1303 flask.jsonify("fake args", kwargs="fake")1304 assert "behavior undefined" in str(e.value)13051306detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1307why, one step back1307def test_url_generation(app, req_ctx):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1308why, one step back1308 @app.route("/hello/<name>", methods=["POST"])detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1309why, one step back1309 def hello():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1310–1318why, one step back1310 pass13111312 assert flask.url_for("hello", name="test x") == "/hello/test%20x"1313 assert (1314 flask.url_for("hello", name="test x", _external=True)1315 == "http://localhost/hello/test%20x"1316 )13171318detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1319–1320why, one step back1319def test_build_error_handler(app):1320 # Test base case, a URL which results in a BuildError.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1321–1323why, one step back1321 with app.test_request_context():1322 pytest.raises(BuildError, flask.url_for, "spam")1323detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1324why, one step back1324 # Verify the error is re-raised if not the current exception.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1325why, one step back1325 try:detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1326why, one step back1326 with app.test_request_context():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1327why, one step back1327 flask.url_for("spam")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1328–1329why, one step back1328 except BuildError as err:1329 error = errMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1330–1331why, one step back1330 try:1331 raise RuntimeError("Test case where BuildError is not current.")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1332why, one step back1332 except RuntimeError:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1333–1334why, one step back1333 pytest.raises(BuildError, app.handle_url_build_error, error, "spam", {})1334detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1335why, one step back1335 # Test a custom handler.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1336why, one step back1336 def handler(error, endpoint, values):detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1337why, one step back1337 # Just a test.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1338–1339why, one step back1338 return "/test_handler/"1339detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1340why, one step back1340 app.url_build_error_handlers.append(handler)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1341–1344why, one step back1341 with app.test_request_context():1342 assert flask.url_for("spam") == "/test_handler/"13431344detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1345–1348why, one step back1345def test_build_error_handler_reraise(app):1346 # Test a custom handler which reraises the BuildError1347 def handler_raises_build_error(error, endpoint, values):1348 raise errorMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1349why, one step back1349detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1350why, one step back1350 app.url_build_error_handlers.append(handler_raises_build_error)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1351–1355why, one step back13511352 with app.test_request_context():1353 pytest.raises(BuildError, flask.url_for, "not.existing")13541355detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1356–1357why, one step back1356def test_url_for_passes_special_values_to_build_error_handler(app):1357 @app.url_build_error_handlers.appendMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1358why, one step back1358 def handler(error, endpoint, values):detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1359why, one step back1359 assert values == {Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1360–1370why, one step back1360 "_external": False,1361 "_anchor": None,1362 "_method": None,1363 "_scheme": None,1364 }1365 return "handled"13661367 with app.test_request_context():1368 flask.url_for("/")13691370detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1371–1372why, one step back1371def test_custom_converters(app, client):1372 from werkzeug.routing import BaseConverterMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1373why, one step back1373detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1374–1375why, one step back1374 class ListConverter(BaseConverter):1375 def to_python(self, value):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1376–1377why, one step back1376 return value.split(",")1377detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1378–1379why, one step back1378 def to_url(self, value):1379 base_to_url = super(ListConverter, self).to_urlMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1380–1384why, one step back1380 return ",".join(base_to_url(x) for x in value)13811382 app.url_map.converters["list"] = ListConverter13831384 @app.route("/<list:args>")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1385why, one step back1385 def index(args):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1386–1390why, one step back1386 return "|".join(args)13871388 assert client.get("/1,2,3").data == b"1|2|3"13891390detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1391why, one step back1391def test_static_files(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1392–1399why, one step back1392 rv = client.get("/static/index.html")1393 assert rv.status_code == 2001394 assert rv.data.strip() == b"<h1>Hello World!</h1>"1395 with app.test_request_context():1396 assert flask.url_for("static", filename="index.html") == "/static/index.html"1397 rv.close()13981399detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1400why, one step back1400def test_static_url_path():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1401–1410why, one step back1401 app = flask.Flask(__name__, static_url_path="/foo")1402 app.testing = True1403 rv = app.test_client().get("/foo/index.html")1404 assert rv.status_code == 2001405 rv.close()14061407 with app.test_request_context():1408 assert flask.url_for("static", filename="index.html") == "/foo/index.html"14091410Merge pull request #3182 from qil026/issue-3134-url-joinDavid Lordbefore adoptiondbd3840
lines 1411–1421why, one step back1411def test_static_url_path_with_ending_slash():1412 app = flask.Flask(__name__, static_url_path="/foo/")1413 app.testing = True1414 rv = app.test_client().get("/foo/index.html")1415 assert rv.status_code == 2001416 rv.close()14171418 with app.test_request_context():1419 assert flask.url_for("static", filename="index.html") == "/foo/index.html"14201421detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1422why, one step back1422def test_static_route_with_host_matching():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1423–1430why, one step back1423 app = flask.Flask(__name__, host_matching=True, static_host="example.com")1424 c = app.test_client()1425 rv = c.get("http://example.com/static/index.html")1426 assert rv.status_code == 2001427 rv.close()1428 with app.test_request_context():1429 rv = flask.url_for("static", filename="index.html", _external=True)1430 assert rv == "http://example.com/static/index.html"detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1431why, one step back1431 # Providing static_host without host_matching=True should error.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1432–1433why, one step back1432 with pytest.raises(Exception):1433 flask.Flask(__name__, static_host="example.com")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1434why, one step back1434 # Providing host_matching=True with static_folder but without static_host should error.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1435why, one step back1435 with pytest.raises(Exception):detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1436–1438why, one step back1436 flask.Flask(__name__, host_matching=True)1437 # Providing host_matching=True without static_host but with static_folder=None should not error.1438 flask.Flask(__name__, host_matching=True, static_folder=None)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1439–1440why, one step back14391440detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1441why, one step back1441def test_request_locals():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1442why, one step back1442 assert repr(flask.g) == "<LocalProxy unbound>"detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1443why, one step back1443 assert not flask.gMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1444–1445why, one step back14441445Merge pull request #2635 from pallets/feature/server-name-routingDavid Lordbefore adoptionf808c20
line 1446why, one step back1446def test_test_app_proper_environ():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1447–1455why, one step back1447 app = flask.Flask(__name__, subdomain_matching=True)1448 app.config.update(SERVER_NAME="localhost.localdomain:5000")1449 client = app.test_client()14501451 @app.route("/")1452 def index():1453 return "Foo"14541455 @app.route("/", subdomain="foo")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1456why, one step back1456 def subdomain():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1457–1480why, one step back1457 return "Foo SubDomain"14581459 rv = client.get("/")1460 assert rv.data == b"Foo"14611462 rv = client.get("/", "http://localhost.localdomain:5000")1463 assert rv.data == b"Foo"14641465 rv = client.get("/", "https://localhost.localdomain:5000")1466 assert rv.data == b"Foo"14671468 app.config.update(SERVER_NAME="localhost.localdomain")1469 rv = client.get("/", "https://localhost.localdomain")1470 assert rv.data == b"Foo"14711472 try:1473 app.config.update(SERVER_NAME="localhost.localdomain:443")1474 rv = client.get("/", "https://localhost.localdomain")1475 # Werkzeug 0.81476 assert rv.status_code == 4041477 except ValueError as e:1478 # Werkzeug 0.71479 assert str(e) == (1480 "the server name provided "detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1481–1482why, one step back1481 "('localhost.localdomain:443') does not match the "1482 "server name from the WSGI environment ('localhost.localdomain')"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1483–1493why, one step back1483 )14841485 try:1486 app.config.update(SERVER_NAME="localhost.localdomain")1487 rv = client.get("/", "http://foo.localhost")1488 # Werkzeug 0.81489 assert rv.status_code == 4041490 except ValueError as e:1491 # Werkzeug 0.71492 assert str(e) == (1493 "the server name provided "detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1494–1495why, one step back1494 "('localhost.localdomain') does not match the "1495 "server name from the WSGI environment ('foo.localhost')"Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1496–1501why, one step back1496 )14971498 rv = client.get("/", "http://foo.localhost.localdomain")1499 assert rv.data == b"Foo SubDomain"15001501detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1502–1503why, one step back1502def test_exception_propagation(app, client):1503 def apprunner(config_key):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1504–1507why, one step back1504 @app.route("/")1505 def index():1506 1 // 01507detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1508–1510why, one step back1508 if config_key is not None:1509 app.config[config_key] = True1510 with pytest.raises(Exception):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1511–1514why, one step back1511 client.get("/")1512 else:1513 assert client.get("/").status_code == 5001514detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1515–1518why, one step back1515 # we have to run this test in an isolated thread because if the1516 # debug flag is set to true and an exception happens the context is1517 # not torn down. This causes other tests that run after this fail1518 # when they expect no exception on the stack.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1519why, one step back1519 for config_key in "TESTING", "PROPAGATE_EXCEPTIONS", "DEBUG", None:detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1520–1522why, one step back1520 t = Thread(target=apprunner, args=(config_key,))1521 t.start()1522 t.join()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1523–1539why, one step back152315241525@pytest.mark.parametrize("debug", [True, False])1526@pytest.mark.parametrize("use_debugger", [True, False])1527@pytest.mark.parametrize("use_reloader", [True, False])1528@pytest.mark.parametrize("propagate_exceptions", [None, True, False])1529def test_werkzeug_passthrough_errors(1530 monkeypatch, debug, use_debugger, use_reloader, propagate_exceptions, app1531):1532 rv = {}15331534 # Mocks werkzeug.serving.run_simple method1535 def run_simple_mock(*args, **kwargs):1536 rv["passthrough_errors"] = kwargs.get("passthrough_errors")15371538 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)1539 app.config["PROPAGATE_EXCEPTIONS"] = propagate_exceptionsdetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1540why, one step back1540 app.run(debug=debug, use_debugger=use_debugger, use_reloader=use_reloader)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1541–1542why, one step back15411542detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1543why, one step back1543def test_max_content_length(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1544–1546why, one step back1544 app.config["MAX_CONTENT_LENGTH"] = 6415451546 @app.before_requestdetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1547why, one step back1547 def always_first():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1548–1551why, one step back1548 flask.request.form["myfile"]1549 assert False15501551 @app.route("/accept", methods=["POST"])detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1552why, one step back1552 def accept_file():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1553–1555why, one step back1553 flask.request.form["myfile"]1554 assert False1555detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1556–1557why, one step back1556 @app.errorhandler(413)1557 def catcher(error):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1558–1563why, one step back1558 return "42"15591560 rv = client.post("/accept", data={"myfile": "foo" * 100})1561 assert rv.data == b"42"15621563detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1564–1566why, one step back1564def test_url_processors(app, client):1565 @app.url_defaults1566 def add_language_code(endpoint, values):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1567–1571why, one step back1567 if flask.g.lang_code is not None and app.url_map.is_endpoint_expecting(1568 endpoint, "lang_code"1569 ):1570 values.setdefault("lang_code", flask.g.lang_code)1571detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1572–1573why, one step back1572 @app.url_value_preprocessor1573 def pull_lang_code(endpoint, values):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1574–1580why, one step back1574 flask.g.lang_code = values.pop("lang_code", None)15751576 @app.route("/<lang_code>/")1577 def index():1578 return flask.url_for("about")15791580 @app.route("/<lang_code>/about")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1581why, one step back1581 def about():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1582–1584why, one step back1582 return flask.url_for("something_else")15831584 @app.route("/foo")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1585why, one step back1585 def something_else():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1586–1592why, one step back1586 return flask.url_for("about", lang_code="en")15871588 assert client.get("/de/").data == b"/de/about"1589 assert client.get("/de/about").data == b"/foo"1590 assert client.get("/foo").data == b"/en/about"15911592detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1593why, one step back1593def test_inject_blueprint_url_defaults(app):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1594–1595why, one step back1594 bp = flask.Blueprint("foo.bar.baz", __name__, template_folder="template")1595detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1596–1597why, one step back1596 @bp.url_defaults1597 def bp_defaults(endpoint, values):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1598–1600why, one step back1598 values["page"] = "login"15991600 @bp.route("/<page>")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1601why, one step back1601 def view(page):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1602–1603why, one step back1602 pass1603detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1604why, one step back1604 app.register_blueprint(bp)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1605why, one step back1605detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1606why, one step back1606 values = dict()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1607–1608why, one step back1607 app.inject_url_defaults("foo.bar.baz.view", values)1608 expected = dict(page="login")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1609why, one step back1609 assert values == expectedMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1610–1613why, one step back16101611 with app.test_request_context("/somepage"):1612 url = flask.url_for("foo.bar.baz.view")1613 expected = "/login"detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1614why, one step back1614 assert url == expectedMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1615–1616why, one step back16151616detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1617why, one step back1617def test_nonascii_pathinfo(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1618–1625why, one step back1618 @app.route(u"/киртест")1619 def index():1620 return "Hello World!"16211622 rv = client.get(u"/киртест")1623 assert rv.data == b"Hello World!"16241625detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1626why, one step back1626def test_debug_mode_complains_after_first_request(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1627–1632why, one step back1627 app.debug = True16281629 @app.route("/")1630 def index():1631 return "Awesome"1632detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1633why, one step back1633 assert not app.got_first_requestMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1634why, one step back1634 assert client.get("/").data == b"Awesome"detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1635why, one step back1635 with pytest.raises(AssertionError) as e:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1636–1637why, one step back16361637 @app.route("/foo")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1638why, one step back1638 def broken():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1639–1645why, one step back1639 return "Meh"16401641 assert "A setup function was called" in str(e)16421643 app.debug = False16441645 @app.route("/foo")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1646why, one step back1646 def working():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1647–1652why, one step back1647 return "Meh"16481649 assert client.get("/foo").data == b"Meh"1650 assert app.got_first_request16511652detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1653why, one step back1653def test_before_first_request_functions(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1654–1666why, one step back1654 got = []16551656 @app.before_first_request1657 def foo():1658 got.append(42)16591660 client.get("/")1661 assert got == [42]1662 client.get("/")1663 assert got == [42]1664 assert app.got_first_request16651666detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1667why, one step back1667def test_before_first_request_functions_concurrent(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1668–1671why, one step back1668 got = []16691670 @app.before_first_request1671 def foo():detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1672why, one step back1672 time.sleep(0.2)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1673–1674why, one step back1673 got.append(42)1674detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1675why, one step back1675 def get_and_assert():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1676why, one step back1676 client.get("/")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1677why, one step back1677 assert got == [42]Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1678why, one step back1678detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1679–1682why, one step back1679 t = Thread(target=get_and_assert)1680 t.start()1681 get_and_assert()1682 t.join()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1683–1685why, one step back1683 assert app.got_first_request16841685detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1686why, one step back1686def test_routing_redirect_debugging(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1687–1693why, one step back1687 app.debug = True16881689 @app.route("/foo/", methods=["GET", "POST"])1690 def foo():1691 return "success"16921693 with client:detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1694why, one step back1694 with pytest.raises(AssertionError) as e:Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1695–1707why, one step back1695 client.post("/foo", data={})1696 assert "http://localhost/foo/" in str(e)1697 assert ("Make sure to directly send " "your POST-request to this URL") in str(e)16981699 rv = client.get("/foo", data={}, follow_redirects=True)1700 assert rv.data == b"success"17011702 app.debug = False1703 with client:1704 rv = client.post("/foo", data={}, follow_redirects=True)1705 assert rv.data == b"success"17061707detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1708why, one step back1708def test_route_decorator_custom_endpoint(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1709–1715why, one step back1709 app.debug = True17101711 @app.route("/foo/")1712 def foo():1713 return flask.request.endpoint17141715 @app.route("/bar/", endpoint="bar")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1716why, one step back1716 def for_bar():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1717–1719why, one step back1717 return flask.request.endpoint17181719 @app.route("/bar/123", endpoint="123")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1720why, one step back1720 def for_bar_foo():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1721–1732why, one step back1721 return flask.request.endpoint17221723 with app.test_request_context():1724 assert flask.url_for("foo") == "/foo/"1725 assert flask.url_for("bar") == "/bar/"1726 assert flask.url_for("123") == "/bar/123"17271728 assert client.get("/foo/").data == b"foo"1729 assert client.get("/bar/").data == b"bar"1730 assert client.get("/bar/123").data == b"123"17311732detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1733why, one step back1733def test_preserve_only_once(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1734–1739why, one step back1734 app.debug = True17351736 @app.route("/fail")1737 def fail_func():1738 1 // 01739detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1740–1741why, one step back1740 for x in range(3):1741 with pytest.raises(ZeroDivisionError):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1742–1743why, one step back1742 client.get("/fail")1743detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1744–1749why, one step back1744 assert flask._request_ctx_stack.top is not None1745 assert flask._app_ctx_stack.top is not None1746 # implicit appctx disappears too1747 flask._request_ctx_stack.top.pop()1748 assert flask._request_ctx_stack.top is None1749 assert flask._app_ctx_stack.top is NoneMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1750–1751why, one step back17501751detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1752why, one step back1752def test_preserve_remembers_exception(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1753why, one step back1753 app.debug = Truedetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1754why, one step back1754 errors = []Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1755–1760why, one step back17551756 @app.route("/fail")1757 def fail_func():1758 1 // 017591760 @app.route("/success")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1761why, one step back1761 def success_func():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1762–1764why, one step back1762 return "Okay"17631764 @app.teardown_requestdetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1765–1766why, one step back1765 def teardown_handler(exc):1766 errors.append(exc)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1767why, one step back1767detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1768–1769why, one step back1768 # After this failure we did not yet call the teardown handler1769 with pytest.raises(ZeroDivisionError):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1770why, one step back1770 client.get("/fail")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1771why, one step back1771 assert errors == []Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1772why, one step back1772detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1773why, one step back1773 # But this request triggers it, and it's an errorMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1774why, one step back1774 client.get("/success")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1775–1776why, one step back1775 assert len(errors) == 21776 assert isinstance(errors[0], ZeroDivisionError)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1777why, one step back1777detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1778why, one step back1778 # At this point another request does nothing.Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1779why, one step back1779 client.get("/success")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1780–1781why, one step back1780 assert len(errors) == 31781 assert errors[1] is NoneMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1782–1783why, one step back17821783detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1784why, one step back1784def test_get_method_on_g(app_ctx):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1785–1786why, one step back1785 assert flask.g.get("x") is None1786 assert flask.g.get("x", 11) == 11detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1787why, one step back1787 flask.g.x = 42Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1788why, one step back1788 assert flask.g.get("x") == 42detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1789why, one step back1789 assert flask.g.x == 42Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1790–1791why, one step back17901791detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1792–1794why, one step back1792def test_g_iteration_protocol(app_ctx):1793 flask.g.foo = 231794 flask.g.bar = 42Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1795–1799why, one step back1795 assert "foo" in flask.g1796 assert "foos" not in flask.g1797 assert sorted(flask.g) == ["bar", "foo"]17981799Merge pull request #2635 from pallets/feature/server-name-routingDavid Lordbefore adoptionf808c20
line 1800why, one step back1800def test_subdomain_basic_support():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1801–1805why, one step back1801 app = flask.Flask(__name__, subdomain_matching=True)1802 app.config["SERVER_NAME"] = "localhost.localdomain"1803 client = app.test_client()18041805 @app.route("/")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1806why, one step back1806 def normal_index():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1807–1809why, one step back1807 return "normal index"18081809 @app.route("/", subdomain="test")detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1810why, one step back1810 def test_index():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1811–1819why, one step back1811 return "test index"18121813 rv = client.get("/", "http://localhost.localdomain/")1814 assert rv.data == b"normal index"18151816 rv = client.get("/", "http://test.localhost.localdomain/")1817 assert rv.data == b"test index"18181819Merge pull request #2635 from pallets/feature/server-name-routingDavid Lordbefore adoptionf808c20
line 1820why, one step back1820def test_subdomain_matching():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1821–1832why, one step back1821 app = flask.Flask(__name__, subdomain_matching=True)1822 client = app.test_client()1823 app.config["SERVER_NAME"] = "localhost.localdomain"18241825 @app.route("/", subdomain="<user>")1826 def index(user):1827 return "index for %s" % user18281829 rv = client.get("/", "http://mitsuhiko.localhost.localdomain/")1830 assert rv.data == b"index for mitsuhiko"18311832Merge pull request #2635 from pallets/feature/server-name-routingDavid Lordbefore adoptionf808c20
line 1833why, one step back1833def test_subdomain_matching_with_ports():Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1834–1846why, one step back1834 app = flask.Flask(__name__, subdomain_matching=True)1835 app.config["SERVER_NAME"] = "localhost.localdomain:3000"1836 client = app.test_client()18371838 @app.route("/", subdomain="<user>")1839 def index(user):1840 return "index for %s" % user18411842 rv = client.get("/", "http://mitsuhiko.localhost.localdomain:3000/")1843 assert rv.data == b"index for mitsuhiko"184418451846@pytest.mark.parametrize("matching", (False, True))Merge pull request #2635 from pallets/feature/server-name-routingDavid Lordbefore adoptionf808c20
lines 1847–1848why, one step back1847def test_subdomain_matching_other_name(matching):1848 app = flask.Flask(__name__, subdomain_matching=matching)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1849–1855why, one step back1849 app.config["SERVER_NAME"] = "localhost.localdomain:3000"1850 client = app.test_client()18511852 @app.route("/")1853 def index():1854 return "", 2041855Merge pull request #2635 from pallets/feature/server-name-routingDavid Lordbefore adoptionf808c20
line 1856why, one step back1856 # ip address can't match nameMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1857–1859why, one step back1857 rv = client.get("/", "http://127.0.0.1:3000/")1858 assert rv.status_code == 404 if matching else 2041859Merge pull request #2635 from pallets/feature/server-name-routingDavid Lordbefore adoptionf808c20
line 1860why, one step back1860 # allow all subdomains if matching is disabledMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1861–1864why, one step back1861 rv = client.get("/", "http://www.localhost.localdomain:3000/")1862 assert rv.status_code == 404 if matching else 20418631864detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1865why, one step back1865def test_multi_route_rules(app, client):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1866–1868why, one step back1866 @app.route("/")1867 @app.route("/<test>/")1868 def index(test="a"):detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1869why, one step back1869 return testMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1870–1876why, one step back18701871 rv = client.open("/")1872 assert rv.data == b"a"1873 rv = client.open("/b/")1874 assert rv.data == b"b"18751876detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1877–1879why, one step back1877def test_multi_route_class_views(app, client):1878 class View(object):1879 def __init__(self, app):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1880–1883why, one step back1880 app.add_url_rule("/", "index", self.index)1881 app.add_url_rule("/<test>/", "index", self.index)18821883 def index(self, test="a"):detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1884why, one step back1884 return testMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1885why, one step back1885detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1886why, one step back1886 _ = View(app)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1887–1892why, one step back1887 rv = client.open("/")1888 assert rv.data == b"a"1889 rv = client.open("/b/")1890 assert rv.data == b"b"18911892detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1893why, one step back1893def test_run_defaults(monkeypatch, app):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1894–1900why, one step back1894 rv = {}18951896 # Mocks werkzeug.serving.run_simple method1897 def run_simple_mock(*args, **kwargs):1898 rv["result"] = "running..."18991900 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1901why, one step back1901 app.run()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1902–1904why, one step back1902 assert rv["result"] == "running..."19031904detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1905why, one step back1905def test_run_server_port(monkeypatch, app):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1906–1908why, one step back1906 rv = {}19071908 # Mocks werkzeug.serving.run_simple methoddetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1909why, one step back1909 def run_simple_mock(hostname, port, application, *args, **kwargs):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1910–1913why, one step back1910 rv["result"] = "running on %s:%s ..." % (hostname, port)19111912 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)1913 hostname, port = "localhost", 8000detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1914why, one step back1914 app.run(hostname, port, debug=True)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1915–1918why, one step back1915 assert rv["result"] == "running on %s:%s ..." % (hostname, port)191619171918@pytest.mark.parametrize(Merge pull request #2928 from vorelq/2926-default-port-overrides-zeroDavid Lordbefore adoptiond9fa28b
line 1919why, one step back1919 "host,port,server_name,expect_host,expect_port",Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1920why, one step back1920 (Merge pull request #2928 from vorelq/2926-default-port-overrides-zeroDavid Lordbefore adoptiond9fa28b
lines 1921–1927why, one step back1921 (None, None, "pocoo.org:8080", "pocoo.org", 8080),1922 ("localhost", None, "pocoo.org:8080", "localhost", 8080),1923 (None, 80, "pocoo.org:8080", "pocoo.org", 80),1924 ("localhost", 80, "pocoo.org:8080", "localhost", 80),1925 ("localhost", 0, "localhost:8080", "localhost", 0),1926 (None, None, "localhost:8080", "localhost", 8080),1927 (None, None, "localhost:0", "localhost", 0),Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1928–1929why, one step back1928 ),1929)Merge pull request #2928 from vorelq/2926-default-port-overrides-zeroDavid Lordbefore adoptiond9fa28b
line 1930why, one step back1930def test_run_from_config(monkeypatch, host, port, server_name, expect_host, expect_port, app):detox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
lines 1931–1933why, one step back1931 def run_simple_mock(hostname, port, *args, **kwargs):1932 assert hostname == expect_host1933 assert port == expect_portMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1934–1935why, one step back19341935 monkeypatch.setattr(werkzeug.serving, "run_simple", run_simple_mock)Merge pull request #2928 from vorelq/2926-default-port-overrides-zeroDavid Lordbefore adoptiond9fa28b
line 1936why, one step back1936 app.config["SERVER_NAME"] = server_namedetox breaks docs test env for some reasonDavid Lordbefore adoption6162ece
line 1937why, one step back1937 app.run(host, port)Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1938–1939why, one step back19381939Merge pull request #2693 from davidism/max-cookie-sizeDavid Lordbefore adoptiond8bf589
line 1940why, one step back1940def test_max_cookie_size(app, client, recwarn):Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1941–1942why, one step back1941 app.config["MAX_COOKIE_SIZE"] = 1001942Merge pull request #2693 from davidism/max-cookie-sizeDavid Lordbefore adoptiond8bf589
lines 1943–1945why, one step back1943 # outside app context, default to Werkzeug static value,1944 # which is also the default config1945 response = flask.Response()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1946why, one step back1946 default = flask.Flask.default_config["MAX_COOKIE_SIZE"]Merge pull request #2693 from davidism/max-cookie-sizeDavid Lordbefore adoptiond8bf589
line 1947why, one step back1947 assert response.max_cookie_size == defaultMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
line 1948why, one step back1948Merge pull request #2693 from davidism/max-cookie-sizeDavid Lordbefore adoptiond8bf589
lines 1949–1951why, one step back1949 # inside app context, use app config1950 with app.app_context():1951 assert flask.Response().max_cookie_size == 100Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1952–1956why, one step back19521953 @app.route("/")1954 def index():1955 r = flask.Response("", status=204)1956 r.set_cookie("foo", "bar" * 100)Merge pull request #2693 from davidism/max-cookie-sizeDavid Lordbefore adoptiond8bf589
line 1957why, one step back1957 return rMerge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1958–1959why, one step back19581959 client.get("/")Merge pull request #2693 from davidism/max-cookie-sizeDavid Lordbefore adoptiond8bf589
lines 1960–1961why, one step back1960 assert len(recwarn) == 11961 w = recwarn.pop()Merge pull request #3183 from singingwolfboy/pre-commitDavid Baumgoldbefore adoption1dda032
lines 1962–1966why, one step back1962 assert "cookie is too large" in str(w.message)19631964 app.config["MAX_COOKIE_SIZE"] = 019651966 client.get("/")Merge pull request #2693 from davidism/max-cookie-sizeDavid Lordbefore adoptiond8bf589
line 1967why, one step back1967 assert len(recwarn) == 0