mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #18023 -- Removed bundled simplejson.
And started the deprecation path for django.utils.simplejson. Thanks Alex Ogier, Clueless, and other contributors for their work on the patch.
This commit is contained in:
@@ -5,6 +5,7 @@ from __future__ import absolute_import
|
||||
import base64
|
||||
import errno
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
from StringIO import StringIO
|
||||
@@ -13,7 +14,7 @@ from django.core.files import temp as tempfile
|
||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||
from django.http.multipartparser import MultiPartParser
|
||||
from django.test import TestCase, client
|
||||
from django.utils import simplejson, unittest
|
||||
from django.utils import unittest
|
||||
|
||||
from . import uploadhandler
|
||||
from .models import FileModel, temp_storage, UPLOAD_TO
|
||||
@@ -78,7 +79,7 @@ class FileUploadTests(TestCase):
|
||||
'wsgi.input': client.FakePayload(payload),
|
||||
}
|
||||
response = self.client.request(**r)
|
||||
received = simplejson.loads(response.content)
|
||||
received = json.loads(response.content)
|
||||
|
||||
self.assertEqual(received['file'], test_string)
|
||||
|
||||
@@ -150,7 +151,7 @@ class FileUploadTests(TestCase):
|
||||
response = self.client.request(**r)
|
||||
|
||||
# The filenames should have been sanitized by the time it got to the view.
|
||||
recieved = simplejson.loads(response.content)
|
||||
recieved = json.loads(response.content)
|
||||
for i, name in enumerate(scary_file_names):
|
||||
got = recieved["file%s" % i]
|
||||
self.assertEqual(got, "hax0rd.txt")
|
||||
@@ -174,7 +175,7 @@ class FileUploadTests(TestCase):
|
||||
'REQUEST_METHOD': 'POST',
|
||||
'wsgi.input': client.FakePayload(payload),
|
||||
}
|
||||
got = simplejson.loads(self.client.request(**r).content)
|
||||
got = json.loads(self.client.request(**r).content)
|
||||
self.assertTrue(len(got['file']) < 256, "Got a long file name (%s characters)." % len(got['file']))
|
||||
|
||||
def test_truncated_multipart_handled_gracefully(self):
|
||||
@@ -200,7 +201,7 @@ class FileUploadTests(TestCase):
|
||||
'REQUEST_METHOD': 'POST',
|
||||
'wsgi.input': client.FakePayload(payload),
|
||||
}
|
||||
got = simplejson.loads(self.client.request(**r).content)
|
||||
got = json.loads(self.client.request(**r).content)
|
||||
self.assertEquals(got, {})
|
||||
|
||||
def test_empty_multipart_handled_gracefully(self):
|
||||
@@ -215,7 +216,7 @@ class FileUploadTests(TestCase):
|
||||
'REQUEST_METHOD': 'POST',
|
||||
'wsgi.input': client.FakePayload(''),
|
||||
}
|
||||
got = simplejson.loads(self.client.request(**r).content)
|
||||
got = json.loads(self.client.request(**r).content)
|
||||
self.assertEquals(got, {})
|
||||
|
||||
def test_custom_upload_handler(self):
|
||||
@@ -231,12 +232,12 @@ class FileUploadTests(TestCase):
|
||||
|
||||
# Small file posting should work.
|
||||
response = self.client.post('/file_uploads/quota/', {'f': smallfile})
|
||||
got = simplejson.loads(response.content)
|
||||
got = json.loads(response.content)
|
||||
self.assertTrue('f' in got)
|
||||
|
||||
# Large files don't go through.
|
||||
response = self.client.post("/file_uploads/quota/", {'f': bigfile})
|
||||
got = simplejson.loads(response.content)
|
||||
got = json.loads(response.content)
|
||||
self.assertTrue('f' not in got)
|
||||
|
||||
def test_broken_custom_upload_handler(self):
|
||||
@@ -274,7 +275,7 @@ class FileUploadTests(TestCase):
|
||||
'field5': u'test7',
|
||||
'file2': (file2, file2a)
|
||||
})
|
||||
got = simplejson.loads(response.content)
|
||||
got = json.loads(response.content)
|
||||
|
||||
self.assertEqual(got.get('file1'), 1)
|
||||
self.assertEqual(got.get('file2'), 2)
|
||||
|
||||
Reference in New Issue
Block a user