Skip to content
Myr

test_testing.py

This file

Path

tests/test_testing.py

424 lines · 11.0 KiB · Python

Last changed by

remove unused module docstringsDavid Lordbefore adoptionf2f027d

History of this file

Take it

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

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 1–4why, one step back
1import click
2import pytest3import werkzeug4

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

line 5why, one step back
5import flask

Merge branch '1.0.x'David Lordbefore adoption05a4e15

line 6why, one step back
6from flask import appcontext_popped

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 7–8why, one step back
7from flask.cli import ScriptInfo
8from flask.json import jsonify

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

lines 9–10why, one step back
9from flask.testing import EnvironBuilder
10from flask.testing import FlaskCliRunner

Fix typo in issue templateGrey Libefore adoptiond7eea1b

line 11why, one step back
11

Merge branch '1.0.x'David Lordbefore adoption05a4e15

lines 12–15why, one step back
12try:
13 import blinker14except ImportError:15 blinker = None

Fix typo in issue templateGrey Libefore adoptiond7eea1b

line 16why, one step back
16

Merge branch '1.0.x'David Lordbefore adoption05a4e15

line 17why, one step back
17

Fix typo in issue templateGrey Libefore adoptiond7eea1b

line 18why, one step back
18def test_environ_defaults_from_config(app, client):

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

lines 19–20why, one step back
19 app.config["SERVER_NAME"] = "example.com:1234"
20 app.config["APPLICATION_ROOT"] = "/foo"

Fix typo in issue templateGrey Libefore adoptiond7eea1b

line 21why, one step back
21

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

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

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 23–26why, one step back
23 def index():
24 return flask.request.url2526 ctx = app.test_request_context()

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

line 27why, one step back
27 assert ctx.request.url == "http://example.com:1234/foo/"

Fix typo in issue templateGrey Libefore adoptiond7eea1b

line 28why, one step back
28

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

lines 29–30why, one step back
29 rv = client.get("/")
30 assert rv.data == b"http://example.com:1234/foo/"

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 31–33why, one step back
31
3233def test_environ_defaults(app, client, app_ctx, req_ctx):

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

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

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 35–38why, one step back
35 def index():
36 return flask.request.url3738 ctx = app.test_request_context()

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

line 39why, one step back
39 assert ctx.request.url == "http://localhost/"

Fix typo in issue templateGrey Libefore adoptiond7eea1b

line 40why, one step back
40 with client:

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

lines 41–42why, one step back
41 rv = client.get("/")
42 assert rv.data == b"http://localhost/"

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 43–45why, one step back
43
4445def test_environ_base_default(app, client, app_ctx):

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

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

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 47–50why, one step back
47 def index():
48 flask.g.user_agent = flask.request.headers["User-Agent"]49 return flask.request.remote_addr50

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

lines 51–52why, one step back
51 rv = client.get("/")
52 assert rv.data == b"127.0.0.1"

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

line 53why, one step back
53 assert flask.g.user_agent == f"werkzeug/{werkzeug.__version__}"

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 54–56why, one step back
54
5556def test_environ_base_modified(app, client, app_ctx):

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

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

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 58–61why, one step back
58 def index():
59 flask.g.user_agent = flask.request.headers["User-Agent"]60 return flask.request.remote_addr61

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

lines 62–66why, one step back
62 client.environ_base["REMOTE_ADDR"] = "0.0.0.0"
63 client.environ_base["HTTP_USER_AGENT"] = "Foo"64 rv = client.get("/")65 assert rv.data == b"0.0.0.0"66 assert flask.g.user_agent == "Foo"

Fix typo in issue templateGrey Libefore adoptiond7eea1b

line 67why, one step back
67

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

lines 68–72why, one step back
68 client.environ_base["REMOTE_ADDR"] = "0.0.0.1"
69 client.environ_base["HTTP_USER_AGENT"] = "Bar"70 rv = client.get("/")71 assert rv.data == b"0.0.0.1"72 assert flask.g.user_agent == "Bar"

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 73–75why, one step back
73
7475def test_client_open_environ(app, client, request):

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

line 76why, one step back
76 @app.route("/index")

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 77–79why, one step back
77 def index():
78 return flask.request.remote_addr79

Merge pull request #3232 from lordmauve/environbuilderDavid Lordbefore adoption5e15850

line 80why, one step back
80 builder = EnvironBuilder(app, path="/index", method="GET")

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 81–83why, one step back
81 request.addfinalizer(builder.close)
8283 rv = client.open(builder)

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

line 84why, one step back
84 assert rv.data == b"127.0.0.1"

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 85–86why, one step back
85
86 environ = builder.get_environ()

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

line 87why, one step back
87 client.environ_base["REMOTE_ADDR"] = "127.0.0.2"

Fix typo in issue templateGrey Libefore adoptiond7eea1b

line 88why, one step back
88 rv = client.open(environ)

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

line 89why, one step back
89 assert rv.data == b"127.0.0.2"

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 90–92why, one step back
90
9192def test_specify_url_scheme(app, client):

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

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

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 94–96why, one step back
94 def index():
95 return flask.request.url96

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

lines 97–98why, one step back
97 ctx = app.test_request_context(url_scheme="https")
98 assert ctx.request.url == "https://localhost/"

Fix typo in issue templateGrey Libefore adoptiond7eea1b

line 99why, one step back
99

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

lines 100–101why, one step back
100 rv = client.get("/", url_scheme="https")
101 assert rv.data == b"https://localhost/"

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 102–104why, one step back
102
103104def test_path_is_url(app):

Merge pull request #3232 from lordmauve/environbuilderDavid Lordbefore adoption5e15850

line 105why, one step back
105 eb = EnvironBuilder(app, "https://example.com/")

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

lines 106–109why, one step back
106 assert eb.url_scheme == "https"
107 assert eb.host == "example.com"108 assert eb.script_root == ""109 assert eb.path == "/"

Merge pull request #3232 from lordmauve/environbuilderDavid Lordbefore adoption5e15850

lines 110–114why, one step back
110
111112def test_environbuilder_json_dumps(app):113 """EnvironBuilder.json_dumps() takes settings from the app."""114 app.config["JSON_AS_ASCII"] = False

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

lines 115–116why, one step back
115 eb = EnvironBuilder(app, json="\u20ac")
116 assert eb.input_stream.read().decode("utf8") == '"\u20ac"'

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 117–120why, one step back
117
118119def test_blueprint_with_subdomain():120 app = flask.Flask(__name__, subdomain_matching=True)

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

lines 121–122why, one step back
121 app.config["SERVER_NAME"] = "example.com:1234"
122 app.config["APPLICATION_ROOT"] = "/foo"

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 123–124why, one step back
123 client = app.test_client()
124

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

line 125why, one step back
125 bp = flask.Blueprint("company", __name__, subdomain="xxx")

Fix typo in issue templateGrey Libefore adoptiond7eea1b

line 126why, one step back
126

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

line 127why, one step back
127 @bp.route("/")

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 128–132why, one step back
128 def index():
129 return flask.request.url130131 app.register_blueprint(bp)132

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

lines 133–134why, one step back
133 ctx = app.test_request_context("/", subdomain="xxx")
134 assert ctx.request.url == "http://xxx.example.com:1234/foo/"

Merge pull request #3104 from eladm26/adding_models_converterDavid Lordbefore adoption2fa30f6

lines 135–137why, one step back
135
136 with ctx:137 assert ctx.request.blueprint == bp.name

Fix typo in issue templateGrey Libefore adoptiond7eea1b

line 138why, one step back
138

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

lines 139–140why, one step back
139 rv = client.get("/", subdomain="xxx")
140 assert rv.data == b"http://xxx.example.com:1234/foo/"

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 141–143why, one step back
141
142143def test_redirect_keep_session(app, client, app_ctx):

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

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

Fix typo in issue templateGrey Libefore adoptiond7eea1b

line 145why, one step back
145 def index():

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

lines 146–149why, one step back
146 if flask.request.method == "POST":
147 return flask.redirect("/getsession")148 flask.session["data"] = "foo"149 return "index"

Fix typo in issue templateGrey Libefore adoptiond7eea1b

line 150why, one step back
150

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

line 151why, one step back
151 @app.route("/getsession")

Fix typo in issue templateGrey Libefore adoptiond7eea1b

line 152why, one step back
152 def get_session():

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

line 153why, one step back
153 return flask.session.get("data", "<missing>")

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 154–155why, one step back
154
155 with client:

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

lines 156–157why, one step back
156 rv = client.get("/getsession")
157 assert rv.data == b"<missing>"

Fix typo in issue templateGrey Libefore adoptiond7eea1b

line 158why, one step back
158

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

lines 159–161why, one step back
159 rv = client.get("/")
160 assert rv.data == b"index"161 assert flask.session.get("data") == "foo"

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

line 162why, one step back
162

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

lines 163–164why, one step back
163 rv = client.post("/", data={}, follow_redirects=True)
164 assert rv.data == b"foo"

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

line 165why, one step back
165 assert flask.session.get("data") == "foo"

Fix typo in issue templateGrey Libefore adoptiond7eea1b

line 166why, one step back
166

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

lines 167–168why, one step back
167 rv = client.get("/getsession")
168 assert rv.data == b"foo"

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 169–171why, one step back
169
170171def test_session_transactions(app, client):

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

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

Fix typo in issue templateGrey Libefore adoptiond7eea1b

line 173why, one step back
173 def index():

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

line 174why, one step back
174 return str(flask.session["foo"])

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 175–178why, one step back
175
176 with client:177 with client.session_transaction() as sess:178 assert len(sess) == 0

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

line 179why, one step back
179 sess["foo"] = [42]

Fix typo in issue templateGrey Libefore adoptiond7eea1b

line 180why, one step back
180 assert len(sess) == 1

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

lines 181–182why, one step back
181 rv = client.get("/")
182 assert rv.data == b"[42]"

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 183–184why, one step back
183 with client.session_transaction() as sess:
184 assert len(sess) == 1

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

line 185why, one step back
185 assert sess["foo"] == [42]

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 186–193why, one step back
186
187188def test_session_transactions_no_null_sessions():189 app = flask.Flask(__name__)190 app.testing = True191192 with app.test_client() as c:193 with pytest.raises(RuntimeError) as e:

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

line 194why, one step back
194 with c.session_transaction():

Fix typo in issue templateGrey Libefore adoptiond7eea1b

line 195why, one step back
195 pass

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

line 196why, one step back
196 assert "Session backend did not open a session" in str(e.value)

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 197–199why, one step back
197
198199def test_session_transactions_keep_context(app, client, req_ctx):

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

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

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 201–209why, one step back
201 req = flask.request._get_current_object()
202 assert req is not None203 with client.session_transaction():204 assert req is flask.request._get_current_object()205206207def test_session_transaction_needs_cookies(app):208 c = app.test_client(use_cookies=False)209 with pytest.raises(RuntimeError) as e:

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

line 210why, one step back
210 with c.session_transaction():

Fix typo in issue templateGrey Libefore adoptiond7eea1b

line 211why, one step back
211 pass

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

line 212why, one step back
212 assert "cookies" in str(e.value)

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 213–217why, one step back
213
214215def test_test_client_context_binding(app, client):216 app.testing = False217

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

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

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 219–220why, one step back
219 def index():
220 flask.g.value = 42

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

line 221why, one step back
221 return "Hello World!"

Fix typo in issue templateGrey Libefore adoptiond7eea1b

line 222why, one step back
222

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

line 223why, one step back
223 @app.route("/other")

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 224–227why, one step back
224 def other():
225 1 // 0226227 with client:

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

line 228why, one step back
228 resp = client.get("/")

Fix typo in issue templateGrey Libefore adoptiond7eea1b

line 229why, one step back
229 assert flask.g.value == 42

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

line 230why, one step back
230 assert resp.data == b"Hello World!"

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 231–232why, one step back
231 assert resp.status_code == 200
232

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

lines 233–235why, one step back
233 resp = client.get("/other")
234 assert not hasattr(flask.g, "value")235 assert b"Internal Server Error" in resp.data

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 236–243why, one step back
236 assert resp.status_code == 500
237 flask.g.value = 23238239 try:240 flask.g.value241 except (AttributeError, RuntimeError):242 pass243 else:

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

line 244why, one step back
244 raise AssertionError("some kind of exception expected")

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 245–250why, one step back
245
246247def test_reuse_client(client):248 c = client249250 with c:

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

line 251why, one step back
251 assert client.get("/").status_code == 404

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 252–253why, one step back
252
253 with c:

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

line 254why, one step back
254 assert client.get("/").status_code == 404

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 255–265why, one step back
255
256257def test_test_client_calls_teardown_handlers(app, client):258 called = []259260 @app.teardown_request261 def remember(error):262 called.append(error)263264 with client:265 assert called == []

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

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

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 267–272why, one step back
267 assert called == []
268 assert called == [None]269270 del called[:]271 with client:272 assert called == []

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

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

Fix typo in issue templateGrey Libefore adoptiond7eea1b

line 274why, one step back
274 assert called == []

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

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

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 276–280why, one step back
276 assert called == [None]
277 assert called == [None, None]278279280def test_full_url_request(app, client):

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

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

Fix typo in issue templateGrey Libefore adoptiond7eea1b

line 282why, one step back
282 def action():

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

line 283why, one step back
283 return "x"

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 284–285why, one step back
284
285 with client:

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

line 286why, one step back
286 rv = client.post("http://domain.com/action?vodka=42", data={"gin": 43})

Fix typo in issue templateGrey Libefore adoptiond7eea1b

line 287why, one step back
287 assert rv.status_code == 200

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

lines 288–289why, one step back
288 assert "gin" in flask.request.form
289 assert "vodka" in flask.request.args

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 290–292why, one step back
290
291292def test_json_request_and_response(app, client):

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

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

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 294–297why, one step back
294 def echo():
295 return jsonify(flask.request.get_json())296297 with client:

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

lines 298–299why, one step back
298 json_data = {"drink": {"gin": 1, "tonic": True}, "price": 10}
299 rv = client.post("/echo", json=json_data)

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 300–308why, one step back
300
301 # Request should be in JSON302 assert flask.request.is_json303 assert flask.request.get_json() == json_data304305 # Response should be in JSON306 assert rv.status_code == 200307 assert rv.is_json308 assert rv.get_json() == json_data

Merge branch '1.0.x'David Lordbefore adoption05a4e15

lines 309–314why, one step back
309
310311@pytest.mark.skipif(blinker is None, reason="blinker is not installed")312def test_client_json_no_app_context(app, client):313 @app.route("/hello", methods=["POST"])314 def hello():

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

line 315why, one step back
315 return f"Hello, {flask.request.json['name']}!"

Merge branch '1.0.x'David Lordbefore adoption05a4e15

line 316why, one step back
316

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

line 317why, one step back
317 class Namespace:

Merge branch '1.0.x'David Lordbefore adoption05a4e15

lines 318–329why, one step back
318 count = 0
319320 def add(self, app):321 self.count += 1322323 ns = Namespace()324325 with appcontext_popped.connected_to(ns.add, app):326 rv = client.post("/hello", json={"name": "Flask"})327328 assert rv.get_data(as_text=True) == "Hello, Flask!"329 assert ns.count == 1

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 330–333why, one step back
330
331332def test_subdomain():333 app = flask.Flask(__name__, subdomain_matching=True)

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

line 334why, one step back
334 app.config["SERVER_NAME"] = "example.com"

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 335–336why, one step back
335 client = app.test_client()
336

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

line 337why, one step back
337 @app.route("/", subdomain="<company_id>")

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 338–341why, one step back
338 def view(company_id):
339 return company_id340341 with app.test_request_context():

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

line 342why, one step back
342 url = flask.url_for("view", company_id="xxx")

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 343–347why, one step back
343
344 with client:345 response = client.get(url)346347 assert 200 == response.status_code

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

line 348why, one step back
348 assert b"xxx" == response.data

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 349–351why, one step back
349
350351def test_nosubdomain(app, client):

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

line 352why, one step back
352 app.config["SERVER_NAME"] = "example.com"

Fix typo in issue templateGrey Libefore adoptiond7eea1b

line 353why, one step back
353

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

line 354why, one step back
354 @app.route("/<company_id>")

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 355–358why, one step back
355 def view(company_id):
356 return company_id357358 with app.test_request_context():

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

line 359why, one step back
359 url = flask.url_for("view", company_id="xxx")

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 360–364why, one step back
360
361 with client:362 response = client.get(url)363364 assert 200 == response.status_code

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

line 365why, one step back
365 assert b"xxx" == response.data

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 366–380why, one step back
366
367368def test_cli_runner_class(app):369 runner = app.test_cli_runner()370 assert isinstance(runner, FlaskCliRunner)371372 class SubRunner(FlaskCliRunner):373 pass374375 app.test_cli_runner_class = SubRunner376 runner = app.test_cli_runner()377 assert isinstance(runner, SubRunner)378379380def test_cli_invoke(app):

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

line 381why, one step back
381 @app.cli.command("hello")

Fix typo in issue templateGrey Libefore adoptiond7eea1b

line 382why, one step back
382 def hello_command():

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

line 383why, one step back
383 click.echo("Hello, World!")

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 384–386why, one step back
384
385 runner = app.test_cli_runner()386 # invoke with command name

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

lines 387–388why, one step back
387 result = runner.invoke(args=["hello"])
388 assert "Hello" in result.output

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 389–390why, one step back
389 # invoke with command object
390 result = runner.invoke(hello_command)

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

line 391why, one step back
391 assert "Hello" in result.output

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 392–394why, one step back
392
393394def test_cli_custom_obj(app):

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

line 395why, one step back
395 class NS:

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 396–401why, one step back
396 called = False
397398 def create_app():399 NS.called = True400 return app401

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

line 402why, one step back
402 @app.cli.command("hello")

Fix typo in issue templateGrey Libefore adoptiond7eea1b

line 403why, one step back
403 def hello_command():

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

line 404why, one step back
404 click.echo("Hello, World!")

Fix typo in issue templateGrey Libefore adoptiond7eea1b

lines 405–409why, one step back
405
406 script_info = ScriptInfo(create_app=create_app)407 runner = app.test_cli_runner()408 runner.invoke(hello_command, obj=script_info)409 assert NS.called

Merge pull request #3157 from fantix/fix-test-client-teardownDavid Lordbefore adoption2c68f86

lines 410–424why, one step back
410
411412def test_client_pop_all_preserved(app, req_ctx, client):413 @app.route("/")414 def index():415 # stream_with_context pushes a third context, preserved by client416 return flask.Response(flask.stream_with_context("hello"))417418 # req_ctx fixture pushed an initial context, not marked preserved419 with client:420 # request pushes a second request context, preserved by client421 client.get("/")422423 # only req_ctx fixture should still be pushed424 assert flask._request_ctx_stack.top is req_ctx