summaryrefslogtreecommitdiff
path: root/tests/regressiontests/httpwrappers
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-08-21 13:55:21 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-08-21 13:55:21 +0000
commitf2477b6450afb99b5c34c54cfd121ddfbabc904e (patch)
tree12a4bab575d1499b5a72d0b0b78225fef83877f9 /tests/regressiontests/httpwrappers
parentc8c159cbbad71deb4d13d6b4e10d4f38817ebdc4 (diff)
Fixed #7233 -- Ensured that QueryDict classes are always unpicklable. This
problem only arose on some systems, since it depends upon the order in which the attributes are pickled. Makes reliable testing kind of tricky. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8460 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/httpwrappers')
-rw-r--r--tests/regressiontests/httpwrappers/tests.py37
1 files changed, 23 insertions, 14 deletions
diff --git a/tests/regressiontests/httpwrappers/tests.py b/tests/regressiontests/httpwrappers/tests.py
index 31b956a99d..5e42ff3b63 100644
--- a/tests/regressiontests/httpwrappers/tests.py
+++ b/tests/regressiontests/httpwrappers/tests.py
@@ -392,17 +392,26 @@ u'\ufffd'
[u'bar', u'\ufffd']
-######################################
-# HttpResponse with Unicode headers #
-######################################
-
->>> r = HttpResponse()
-
+########################
+# Pickling a QueryDict #
+########################
+>>> import pickle
+>>> q = QueryDict('a=b&c=d')
+>>> q1 = pickle.loads(pickle.dumps(q))
+>>> q == q1
+True
+
+######################################
+# HttpResponse with Unicode headers #
+######################################
+
+>>> r = HttpResponse()
+
If we insert a unicode value it will be converted to an ascii
string. This makes sure we comply with the HTTP specifications.
-
->>> r['value'] = u'test value'
->>> isinstance(r['value'], str)
+
+>>> r['value'] = u'test value'
+>>> isinstance(r['value'], str)
True
An error is raised When a unicode object with non-ascii is assigned.
@@ -411,10 +420,10 @@ An error is raised When a unicode object with non-ascii is assigned.
Traceback (most recent call last):
...
UnicodeEncodeError: ..., HTTP response headers must be in US-ASCII format
-
-The response also converts unicode keys to strings.
-
->>> r[u'test'] = 'testing key'
+
+The response also converts unicode keys to strings.
+
+>>> r[u'test'] = 'testing key'
>>> l = list(r.items())
>>> l.sort()
>>> l[1]
@@ -426,7 +435,7 @@ It will also raise errors for keys with non-ascii data.
Traceback (most recent call last):
...
UnicodeEncodeError: ..., HTTP response headers must be in US-ASCII format
-
+
"""
from django.http import QueryDict, HttpResponse