<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -362,12 +362,18 @@ class Client(object):
         else:
             post_data = data
 
+        # Make `data` into a querystring only if it's not already a string. If
+        # it is a string, we'll assume that the caller has already encoded it.
+        query_string = None
+        if not isinstance(data, basestring):
+            query_string = urlencode(data, doseq=True)
+
         parsed = urlparse(path)
         r = {
             'CONTENT_LENGTH': len(post_data),
             'CONTENT_TYPE':   content_type,
             'PATH_INFO':      urllib.unquote(parsed[2]),
-            'QUERY_STRING':   urlencode(data, doseq=True) or parsed[4],
+            'QUERY_STRING':   query_string or parsed[4],
             'REQUEST_METHOD': 'PUT',
             'wsgi.input':     FakePayload(post_data),
         }</diff>
      <filename>django/test/client.py</filename>
    </modified>
    <modified>
      <diff>@@ -574,6 +574,23 @@ class RequestMethodTests(TestCase):
         self.assertEqual(response.status_code, 200)
         self.assertEqual(response.content, 'request method: DELETE')
 
+class RequestMethodStringDataTests(TestCase):
+    def test_post(self):
+        &quot;Request a view with string data via request method POST&quot;
+        # Regression test for #11371
+        data = u'{&quot;test&quot;: &quot;json&quot;}'
+        response = self.client.post('/test_client_regress/request_methods/', data=data, content_type='application/json')
+        self.assertEqual(response.status_code, 200)
+        self.assertEqual(response.content, 'request method: POST')
+
+    def test_put(self):
+        &quot;Request a view with string data via request method PUT&quot;
+        # Regression test for #11371
+        data = u'{&quot;test&quot;: &quot;json&quot;}'
+        response = self.client.put('/test_client_regress/request_methods/', data=data, content_type='application/json')
+        self.assertEqual(response.status_code, 200)
+        self.assertEqual(response.content, 'request method: PUT')
+
 class QueryStringTests(TestCase):
     def test_get_like_requests(self):
         for method_name in ('get','head','options','put','delete'):</diff>
      <filename>tests/regressiontests/test_client_regress/models.py</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>dd51b0ec1bf62058c548fca8900022bb1b90d36a</id>
    </parent>
  </parents>
  <author>
    <name>jacob</name>
    <email>jacob@bcc190cf-cafb-0310-a4f2-bffc1f526a37</email>
  </author>
  <url>http://github.com/mrts/django/commit/014b375d073816684ed4de6aa589864efd2f81d1</url>
  <id>014b375d073816684ed4de6aa589864efd2f81d1</id>
  <committed-date>2009-10-26T08:02:54-07:00</committed-date>
  <authored-date>2009-10-26T08:02:54-07:00</authored-date>
  <message>Fixed #11371: Made `django.test.Client.put()` work for non-form-data PUT (i.e. JSON, etc.). Thanks, phyfus.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@11656 bcc190cf-cafb-0310-a4f2-bffc1f526a37</message>
  <tree>4ea5bbd78c6f471a3a2920957dd25a8fe74da57a</tree>
  <committer>
    <name>jacob</name>
    <email>jacob@bcc190cf-cafb-0310-a4f2-bffc1f526a37</email>
  </committer>
</commit>
