summaryrefslogtreecommitdiff
path: root/tests/regressiontests/file_uploads/tests.py
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2012-04-29 19:58:00 +0200
committerAymeric Augustin <aymeric.augustin@m4x.org>2012-04-29 19:58:00 +0200
commitcec6bd5a59547dc97fe98975c570fc27a1e970be (patch)
treed084ff2008e4bba125c4b28297d6469992f2ec95 /tests/regressiontests/file_uploads/tests.py
parentee0a7c741e98214bac7eeb60b848cf099ff28836 (diff)
downloaddjango-cec6bd5a59547dc97fe98975c570fc27a1e970be.tar.gz
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.
Diffstat (limited to 'tests/regressiontests/file_uploads/tests.py')
-rw-r--r--tests/regressiontests/file_uploads/tests.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/tests/regressiontests/file_uploads/tests.py b/tests/regressiontests/file_uploads/tests.py
index ffa2017a5e..b6191ba033 100644
--- a/tests/regressiontests/file_uploads/tests.py
+++ b/tests/regressiontests/file_uploads/tests.py
@@ -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)