MCPcopy
hub / github.com/pallets/flask / test_max_cookie_size

Function test_max_cookie_size

tests/test_basic.py:1922–1949  ·  view source on GitHub ↗
(app, client, recwarn)

Source from the content-addressed store, hash-verified

1920
1921
1922def test_max_cookie_size(app, client, recwarn):
1923 app.config["MAX_COOKIE_SIZE"] = 100
1924
1925 # outside app context, default to Werkzeug static value,
1926 # which is also the default config
1927 response = flask.Response()
1928 default = flask.Flask.default_config["MAX_COOKIE_SIZE"]
1929 assert response.max_cookie_size == default
1930
1931 # inside app context, use app config
1932 with app.app_context():
1933 assert flask.Response().max_cookie_size == 100
1934
1935 @app.route("/")
1936 def index():
1937 r = flask.Response("", status=204)
1938 r.set_cookie("foo", "bar" * 100)
1939 return r
1940
1941 client.get("/")
1942 assert len(recwarn) == 1
1943 w = recwarn.pop()
1944 assert "cookie is too large" in str(w.message)
1945
1946 app.config["MAX_COOKIE_SIZE"] = 0
1947
1948 client.get("/")
1949 assert len(recwarn) == 0
1950
1951
1952@require_cpython_gc

Callers

nothing calls this directly

Calls 3

app_contextMethod · 0.80
getMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected