From: Rasmus Scholer (TimelineX) Date: Tue, 3 Mar 2015 02:41:00 +0000 (+0100) Subject: Created test case for using bytes and bytearray objects with files argument to Request. X-Git-Tag: v2.6.0~10^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=326f77d57c3fdb45bf1d263a8b4ecef781f39850;p=services%2Fpython-requests.git Created test case for using bytes and bytearray objects with files argument to Request. --- diff --git a/test_requests.py b/test_requests.py index 6e52784..4f38b04 100755 --- a/test_requests.py +++ b/test_requests.py @@ -935,6 +935,19 @@ class RequestsTestCase(unittest.TestCase): assert 'multipart/form-data' in p.headers['Content-Type'] + def test_can_send_bytes_bytearray_objects_with_files(self): + # Test bytes: + data = {'a': 0.0} + files = {'b': b'foo'} + r = requests.Request('POST', httpbin('post'), data=data, files=files) + p = r.prepare() + assert 'multipart/form-data' in p.headers['Content-Type'] + # Test bytearrays: + files = {'b': bytearray(b'foo')} + r = requests.Request('POST', httpbin('post'), data=data, files=files) + p = r.prepare() + assert 'multipart/form-data' in p.headers['Content-Type'] + def test_can_send_file_object_with_non_string_filename(self): f = io.BytesIO() f.name = 2