summaryrefslogtreecommitdiff
path: root/test/test_withdummy.py
diff options
context:
space:
mode:
authorAndrey Petrov <andrey.petrov@shazow.net>2013-11-29 17:11:45 -0500
committerAndrey Petrov <andrey.petrov@shazow.net>2013-11-29 17:11:45 -0500
commiteefde5ca3c2d07764b02475d84a0b8b41dc15b31 (patch)
treeceab1b3cabbdaaac989981b4c9dfa03a121869ec /test/test_withdummy.py
parent9796a765ceab81aa15b4ad3c61e70e4f71748cf9 (diff)
downloadurllib3-filepost-stream.tar.gz
Importing old branch for posterity.filepost-stream
Original message: My very ambitious attempt at allowing streamable iterator files for POST uploading. Not too happy with it yet.
Diffstat (limited to 'test/test_withdummy.py')
-rw-r--r--test/test_withdummy.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/test/test_withdummy.py b/test/test_withdummy.py
index a5f79f33..69e4efb7 100644
--- a/test/test_withdummy.py
+++ b/test/test_withdummy.py
@@ -21,7 +21,7 @@ class TestConnectionPool(unittest.TestCase):
r = self.http_pool.get_url('/', retries=1)
if r.data != "Dummy server!":
raise Exception("Got unexpected response: %s" % r.data)
- except Exception, e:
+ except MaxRetryError, e:
raise Exception("Dummy server not running, make sure HOST and PORT correspond to the dummy server: %s" % e.message)
return super(TestConnectionPool, self).__init__(*args, **kw)
@@ -57,11 +57,23 @@ class TestConnectionPool(unittest.TestCase):
r = self.http_pool.post_url('/upload', fields=fields)
self.assertEquals(r.status, 200, r.data)
- def test_unicode_upload(self):
- fields = {
- u'\xe2\x99\xa5': (u'\xe2\x99\xa5.txt', u'\xe2\x99\xa5'),
+ def _make_fields(self, s):
+ return {
+ u'upload_param': s,
+ u'upload_filename': '%s.txt' % s,
+ u'upload_size': u'3',
+ s: ('%s.txt' % s, s),
}
+ def test_unicode_decoded(self):
+ fields = self._make_fields('\xe2\x99\xa5')
+
+ r = self.http_pool.post_url('/upload', fields=fields)
+ self.assertEquals(r.status, 200, r.data)
+
+ def test_unicode_encoded(self):
+ fields = self._make_fields(u'\u2665')
+
r = self.http_pool.post_url('/upload', fields=fields)
self.assertEquals(r.status, 200, r.data)