summaryrefslogtreecommitdiff
path: root/django/test/client.py
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2007-09-15 21:42:51 +0000
committerAdrian Holovaty <adrian@holovaty.com>2007-09-15 21:42:51 +0000
commit5ce2e6c2c827cf877f73bf0e42e6afb7e6a71ccf (patch)
tree8c8c2fb8329e2db7dbfcf2c47026a11ff079e5c5 /django/test/client.py
parentea9cd5421382c047e2cc140bd6736b54ba660793 (diff)
queryset-refactor: Merged to [6220]
git-svn-id: http://code.djangoproject.com/svn/django/branches/queryset-refactor@6337 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/test/client.py')
-rw-r--r--django/test/client.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/django/test/client.py b/django/test/client.py
index c3e221554f..faacc5bf9e 100644
--- a/django/test/client.py
+++ b/django/test/client.py
@@ -16,6 +16,7 @@ from django.test import signals
from django.utils.functional import curry
from django.utils.encoding import smart_str
from django.utils.http import urlencode
+from django.utils.itercompat import is_iterable
BOUNDARY = 'BoUnDaRyStRiNg'
MULTIPART_CONTENT = 'multipart/form-data; boundary=%s' % BOUNDARY
@@ -74,21 +75,22 @@ def encode_multipart(boundary, data):
'',
value.read()
])
- elif hasattr(value, '__iter__'):
- for item in value:
+ else:
+ if not isinstance(value, basestring) and is_iterable(value):
+ for item in value:
+ lines.extend([
+ '--' + boundary,
+ 'Content-Disposition: form-data; name="%s"' % to_str(key),
+ '',
+ to_str(item)
+ ])
+ else:
lines.extend([
'--' + boundary,
'Content-Disposition: form-data; name="%s"' % to_str(key),
'',
- to_str(item)
+ to_str(value)
])
- else:
- lines.extend([
- '--' + boundary,
- 'Content-Disposition: form-data; name="%s"' % to_str(key),
- '',
- to_str(value)
- ])
lines.extend([
'--' + boundary + '--',