MCPcopy Create free account
hub / github.com/pallets/flask / test_limit_config

Function test_limit_config

tests/test_request.py:25–54  ·  view source on GitHub ↗
(app: Flask)

Source from the content-addressed store, hash-verified

23
24
25def test_limit_config(app: Flask):
26 app.config["MAX_CONTENT_LENGTH"] = 100
27 app.config["MAX_FORM_MEMORY_SIZE"] = 50
28 app.config["MAX_FORM_PARTS"] = 3
29 r = Request({})
30
31 # no app context, use Werkzeug defaults
32 assert r.max_content_length is None
33 assert r.max_form_memory_size == 500_000
34 assert r.max_form_parts == 1_000
35
36 # in app context, use config
37 with app.app_context():
38 assert r.max_content_length == 100
39 assert r.max_form_memory_size == 50
40 assert r.max_form_parts == 3
41
42 # regardless of app context, use override
43 r.max_content_length = 90
44 r.max_form_memory_size = 30
45 r.max_form_parts = 4
46
47 assert r.max_content_length == 90
48 assert r.max_form_memory_size == 30
49 assert r.max_form_parts == 4
50
51 with app.app_context():
52 assert r.max_content_length == 90
53 assert r.max_form_memory_size == 30
54 assert r.max_form_parts == 4
55
56
57def test_trusted_hosts_config(app: Flask) -> None:

Callers

nothing calls this directly

Calls 2

RequestClass · 0.90
app_contextMethod · 0.80

Tested by

no test coverage detected