summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2012-08-28 20:59:56 +0200
committerClaude Paroz <claude@2xlibre.net>2012-08-29 11:20:32 +0200
commitebc773ada3e4f40cf5084268387b873d7fe22e8b (patch)
tree88e136b190e480ed4c8c2310de408a268f4367b2 /tests
parent9eafb6592e9ed27a59cb3cd9920c44cf230a6c65 (diff)
Replaced many smart_bytes by force_bytes
In all those occurrences, we didn't care about preserving the lazy status of the strings, but we really wanted to obtain a real bytestring.
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/admin_util/tests.py2
-rw-r--r--tests/regressiontests/admin_views/tests.py8
-rw-r--r--tests/regressiontests/file_uploads/tests.py6
-rw-r--r--tests/regressiontests/file_uploads/views.py4
4 files changed, 10 insertions, 10 deletions
diff --git a/tests/regressiontests/admin_util/tests.py b/tests/regressiontests/admin_util/tests.py
index 6b6dad4336..d04740ce95 100644
--- a/tests/regressiontests/admin_util/tests.py
+++ b/tests/regressiontests/admin_util/tests.py
@@ -171,7 +171,7 @@ class UtilTests(unittest.TestCase):
)
self.assertEqual(
label_for_field("__str__", Article),
- b"article"
+ str("article")
)
self.assertRaises(
diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py
index 679e3a0346..cf7d4855fb 100644
--- a/tests/regressiontests/admin_views/tests.py
+++ b/tests/regressiontests/admin_views/tests.py
@@ -30,7 +30,7 @@ from django.template.response import TemplateResponse
from django.test import TestCase
from django.utils import formats, translation, unittest
from django.utils.cache import get_max_age
-from django.utils.encoding import iri_to_uri, smart_bytes
+from django.utils.encoding import iri_to_uri, force_bytes
from django.utils.html import escape
from django.utils.http import urlencode
from django.utils import six
@@ -84,7 +84,7 @@ class AdminViewBasicTest(TestCase):
content.
"""
self.assertEqual(response.status_code, 200)
- self.assertTrue(response.content.index(smart_bytes(text1)) < response.content.index(smart_bytes(text2)),
+ self.assertTrue(response.content.index(force_bytes(text1)) < response.content.index(force_bytes(text2)),
failing_msg
)
@@ -1378,9 +1378,9 @@ class AdminViewStringPrimaryKeyTest(TestCase):
logentry.content_type = None
logentry.save()
- counted_presence_before = response.content.count(smart_bytes(should_contain))
+ counted_presence_before = response.content.count(force_bytes(should_contain))
response = self.client.get('/test_admin/admin/')
- counted_presence_after = response.content.count(smart_bytes(should_contain))
+ counted_presence_after = response.content.count(force_bytes(should_contain))
self.assertEqual(counted_presence_before - 1,
counted_presence_after)
diff --git a/tests/regressiontests/file_uploads/tests.py b/tests/regressiontests/file_uploads/tests.py
index 19af992a36..a545ed649e 100644
--- a/tests/regressiontests/file_uploads/tests.py
+++ b/tests/regressiontests/file_uploads/tests.py
@@ -12,7 +12,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.encoding import smart_bytes
+from django.utils.encoding import force_bytes
from django.utils.six import StringIO
from django.utils import unittest
@@ -54,7 +54,7 @@ class FileUploadTests(TestCase):
post_data[key + '_hash'] = hashlib.sha1(post_data[key].read()).hexdigest()
post_data[key].seek(0)
except AttributeError:
- post_data[key + '_hash'] = hashlib.sha1(smart_bytes(post_data[key])).hexdigest()
+ post_data[key + '_hash'] = hashlib.sha1(force_bytes(post_data[key])).hexdigest()
response = self.client.post('/file_uploads/verify/', post_data)
@@ -68,7 +68,7 @@ class FileUploadTests(TestCase):
'Content-Type: application/octet-stream',
'Content-Transfer-Encoding: base64',
'',
- base64.b64encode(smart_bytes(test_string)).decode('ascii'),
+ base64.b64encode(force_bytes(test_string)).decode('ascii'),
'--' + client.BOUNDARY + '--',
'',
]).encode('utf-8')
diff --git a/tests/regressiontests/file_uploads/views.py b/tests/regressiontests/file_uploads/views.py
index 95b2124fd9..fcf32cecea 100644
--- a/tests/regressiontests/file_uploads/views.py
+++ b/tests/regressiontests/file_uploads/views.py
@@ -7,7 +7,7 @@ import os
from django.core.files.uploadedfile import UploadedFile
from django.http import HttpResponse, HttpResponseServerError
from django.utils import six
-from django.utils.encoding import smart_bytes
+from django.utils.encoding import force_bytes
from .models import FileModel, UPLOAD_TO
from .tests import UNICODE_FILENAME
@@ -46,7 +46,7 @@ def file_upload_view_verify(request):
if isinstance(value, UploadedFile):
new_hash = hashlib.sha1(value.read()).hexdigest()
else:
- new_hash = hashlib.sha1(smart_bytes(value)).hexdigest()
+ new_hash = hashlib.sha1(force_bytes(value)).hexdigest()
if new_hash != submitted_hash:
return HttpResponseServerError()