File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -275,6 +275,34 @@ def test_repr_with_password(self):
275275 d = self ._get_instance (password = "pwd" )
276276 assert repr (d ) == "MultiDict([('password', '******')])"
277277
278+ def test_from_multipart (self ):
279+ from io import BytesIO
280+
281+ from multipart import MultipartParser
282+
283+ data = (
284+ b"--foobar\r \n "
285+ b'Content-Disposition: form-data; name="foo"\r \n '
286+ b"\r \n "
287+ b"bar\r \n "
288+ b"--foobar\r \n "
289+ b'Content-Disposition: form-data; name="fizz"; filename="fizz.txt"\r \n '
290+ b"Content-type: application/octet-stream\r \n "
291+ b"\r \n "
292+ b"buzz\r \n "
293+ b"\r \n "
294+ b"--foobar--\r \n "
295+ )
296+ body = BytesIO (data )
297+ body .seek (0 )
298+ mp = MultipartParser (body , b"foobar" )
299+ inst = self .klass .from_multipart (mp )
300+ assert inst ["foo" ] == "bar"
301+ fizz = inst ["fizz" ]
302+ assert isinstance (fizz , multidict .MultiDictFile )
303+ assert fizz .filename == "fizz.txt"
304+ assert fizz .value == b"buzz\r \n "
305+
278306
279307class TestNestedMultiDict (BaseDictTests ):
280308 klass = multidict .NestedMultiDict
You can’t perform that action at this time.
0 commit comments