Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[py3] Fixed contrib.formtools tests

  • Loading branch information...
commit 363dbd920e9b77da83895598f0fc9f7f835df65d 1 parent a025b75
@claudep claudep authored
View
15 django/contrib/formtools/tests/__init__.py
@@ -17,6 +17,7 @@
from django.contrib.formtools.tests.forms import *
success_string = "Done was called!"
+success_string_encoded = success_string.encode()
class TestFormPreview(preview.FormPreview):
def get_context(self, request, form):
@@ -99,11 +100,11 @@ def test_form_submit(self):
# show we previously saw first stage of the form.
self.test_data.update({'stage':2})
response = self.client.post('/preview/', self.test_data)
- self.assertNotEqual(response.content, success_string)
+ self.assertNotEqual(response.content, success_string_encoded)
hash = self.preview.security_hash(None, TestForm(self.test_data))
self.test_data.update({'hash': hash})
response = self.client.post('/preview/', self.test_data)
- self.assertEqual(response.content, success_string)
+ self.assertEqual(response.content, success_string_encoded)
def test_bool_submit(self):
"""
@@ -123,7 +124,7 @@ def test_bool_submit(self):
self.test_data.update({'hash': hash, 'bool1': 'False'})
with warnings.catch_warnings(record=True):
response = self.client.post('/preview/', self.test_data)
- self.assertEqual(response.content, success_string)
+ self.assertEqual(response.content, success_string_encoded)
def test_form_submit_good_hash(self):
"""
@@ -134,11 +135,11 @@ def test_form_submit_good_hash(self):
# show we previously saw first stage of the form.
self.test_data.update({'stage':2})
response = self.client.post('/preview/', self.test_data)
- self.assertNotEqual(response.content, success_string)
+ self.assertNotEqual(response.content, success_string_encoded)
hash = utils.form_hmac(TestForm(self.test_data))
self.test_data.update({'hash': hash})
response = self.client.post('/preview/', self.test_data)
- self.assertEqual(response.content, success_string)
+ self.assertEqual(response.content, success_string_encoded)
def test_form_submit_bad_hash(self):
@@ -151,11 +152,11 @@ def test_form_submit_bad_hash(self):
self.test_data.update({'stage':2})
response = self.client.post('/preview/', self.test_data)
self.assertEqual(response.status_code, 200)
- self.assertNotEqual(response.content, success_string)
+ self.assertNotEqual(response.content, success_string_encoded)
hash = utils.form_hmac(TestForm(self.test_data)) + "bad"
self.test_data.update({'hash': hash})
response = self.client.post('/previewpreview/', self.test_data)
- self.assertNotEqual(response.content, success_string)
+ self.assertNotEqual(response.content, success_string_encoded)
class FormHmacTests(unittest.TestCase):
View
4 django/contrib/formtools/wizard/storage/base.py
@@ -1,6 +1,5 @@
from django.core.files.uploadedfile import UploadedFile
from django.utils.datastructures import MultiValueDict
-from django.utils.encoding import smart_bytes
from django.utils.functional import lazy_property
from django.utils import six
@@ -74,8 +73,7 @@ def get_step_files(self, step):
files = {}
for field, field_dict in six.iteritems(wizard_files):
- field_dict = dict((smart_bytes(k), v)
- for k, v in six.iteritems(field_dict))
+ field_dict = field_dict.copy()
tmp_name = field_dict.pop('tmp_name')
files[field] = UploadedFile(
file=self.file_storage.open(tmp_name), **field_dict)
View
2  django/http/__init__.py
@@ -193,7 +193,7 @@ def get_signed_cookie(self, key, default=RAISE_ERROR, salt='', max_age=None):
default argument in which case that value will be returned instead.
"""
try:
- cookie_value = self.COOKIES[key].encode('utf-8')
+ cookie_value = self.COOKIES[key]
except KeyError:
if default is not RAISE_ERROR:
return default
Please sign in to comment.
Something went wrong with that request. Please try again.