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

Function test_environ_builder_unicode_file_mix

tests/test_test.py:337–358  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

335
336
337def test_environ_builder_unicode_file_mix():
338 for use_tempfile in False, True:
339 f = FileStorage(BytesIO(rb"\N{SNOWMAN}"), "snowman.txt")
340 d = MultiDict(dict(f=f, s="\N{SNOWMAN}"))
341 stream, length, boundary = stream_encode_multipart(
342 d, use_tempfile, threshold=150
343 )
344 assert isinstance(stream, BytesIO) != use_tempfile
345
346 _, form, files = parse_form_data(
347 {
348 "wsgi.input": stream,
349 "CONTENT_LENGTH": str(length),
350 "CONTENT_TYPE": f'multipart/form-data; boundary="{boundary}"',
351 }
352 )
353 assert form["s"] == "\N{SNOWMAN}"
354 assert files["f"].name == "f"
355 assert files["f"].filename == "snowman.txt"
356 assert files["f"].read() == rb"\N{SNOWMAN}"
357 stream.close()
358 files["f"].close()
359
360
361def test_environ_builder_empty_file():

Callers

nothing calls this directly

Calls 6

FileStorageClass · 0.90
MultiDictClass · 0.90
stream_encode_multipartFunction · 0.90
parse_form_dataFunction · 0.90
readMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected