added unicode strings

This commit is contained in:
barberj
2012-04-20 23:30:45 -04:00
committed by Shivaram Lingamneni
parent 0a7d98871c
commit 3288426f2b
2 changed files with 10 additions and 1 deletions
+1 -1
View File
@@ -348,7 +348,7 @@ class Request(object):
else:
fn = guess_filename(v) or k
fp = v
if isinstance(fp, bytes):
if isinstance(fp, (bytes, str)):
fp = StringIO(fp)
fields.update({k: (fn, fp.read())})
+9
View File
@@ -344,6 +344,15 @@ class RequestsTestSuite(TestSetup, TestBaseMixin, unittest.TestCase):
post3 = post(url, files={'fname.txt': 'fdata', 'fname2.txt':open(__file__,'rb')})
self.assertEqual(post3.status_code, 200)
post4 = post(url, files={'fname.txt': u'fdata'})
self.assertEqual(post4.status_code, 200)
post5 = post(url, files={'file': ('file.txt', 'more fdata')})
self.assertEqual(post5.status_code, 200)
post6 = post(url, files={'fname.txt': u'\xe9'})
self.assertEqual(post6.status_code, 200)
def test_nonzero_evaluation(self):
for service in SERVICES: