MCPcopy Create free account
hub / github.com/pallets/werkzeug / test_headers

Method test_headers

tests/test_formparser.py:351–371  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

349 assert data.form["foo"] == "a string"
350
351 def test_headers(self):
352 data = (
353 b"--foo\r\n"
354 b'Content-Disposition: form-data; name="foo"; filename="foo.txt"\r\n'
355 b"X-Custom-Header: blah\r\n"
356 b"Content-Type: text/plain; charset=utf-8\r\n\r\n"
357 b"file contents, just the contents\r\n"
358 b"--foo--"
359 )
360 with Request.from_values(
361 input_stream=io.BytesIO(data),
362 content_length=len(data),
363 content_type="multipart/form-data; boundary=foo",
364 method="POST",
365 ) as req:
366 foo = req.files["foo"]
367 assert foo.mimetype == "text/plain"
368 assert foo.mimetype_params == {"charset": "utf-8"}
369 assert foo.headers["content-type"] == foo.content_type
370 assert foo.content_type == "text/plain; charset=utf-8"
371 assert foo.headers["x-custom-header"] == "blah"
372
373 @pytest.mark.parametrize("ending", [b"\n", b"\r", b"\r\n"])
374 def test_nonstandard_line_endings(self, ending: bytes):

Callers

nothing calls this directly

Calls 1

from_valuesMethod · 0.80

Tested by

no test coverage detected