MCPcopy
hub / github.com/pallets/werkzeug / test_storage_classes

Function test_storage_classes

tests/test_wrappers.py:1043–1068  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1041
1042
1043def test_storage_classes():
1044 class MyRequest(wrappers.Request):
1045 dict_storage_class = dict
1046 list_storage_class = list
1047 parameter_storage_class = dict
1048
1049 req = MyRequest.from_values("/?foo=baz", headers={"Cookie": "foo=bar"})
1050 assert type(req.cookies) is dict # noqa: E721
1051 assert req.cookies == {"foo": "bar"}
1052 assert type(req.access_route) is list # noqa: E721
1053
1054 assert type(req.args) is dict # noqa: E721
1055 assert type(req.values) is CombinedMultiDict # noqa: E721
1056 assert req.values["foo"] == "baz"
1057
1058 req = wrappers.Request.from_values(headers={"Cookie": "foo=bar;foo=baz"})
1059 assert type(req.cookies) is ImmutableMultiDict # noqa: E721
1060 assert req.cookies.to_dict() == {"foo": "bar"}
1061
1062 # it is possible to have multiple cookies with the same name
1063 assert req.cookies.getlist("foo") == ["bar", "baz"]
1064 assert type(req.access_route) is ImmutableList # noqa: E721
1065
1066 MyRequest.list_storage_class = tuple
1067 req = MyRequest.from_values()
1068 assert type(req.access_route) is tuple # noqa: E721
1069
1070
1071def test_response_headers_passthrough():

Callers

nothing calls this directly

Calls 3

from_valuesMethod · 0.80
to_dictMethod · 0.80
getlistMethod · 0.45

Tested by

no test coverage detected