From 363dbd920e9b77da83895598f0fc9f7f835df65d Mon Sep 17 00:00:00 2001
From: Claude Paroz <claude@2xlibre.net>
Date: Mon, 13 Aug 2012 21:07:51 +0200
Subject: [PATCH] [py3] Fixed contrib.formtools tests

---
 django/contrib/formtools/tests/__init__.py      | 15 ++++++++-------
 django/contrib/formtools/wizard/storage/base.py |  4 +---
 django/http/__init__.py                         |  2 +-
 3 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/django/contrib/formtools/tests/__init__.py b/django/contrib/formtools/tests/__init__.py
index 8a3027bc08..f3537f4afd 100644
--- a/django/contrib/formtools/tests/__init__.py
+++ b/django/contrib/formtools/tests/__init__.py
@@ -17,6 +17,7 @@ from django.contrib.formtools.tests.wizard import *
 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 @@ class PreviewTests(TestCase):
         # 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 @@ class PreviewTests(TestCase):
         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 @@ class PreviewTests(TestCase):
         # 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 @@ class PreviewTests(TestCase):
         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):
diff --git a/django/contrib/formtools/wizard/storage/base.py b/django/contrib/formtools/wizard/storage/base.py
index 05c9f6f121..aafc833484 100644
--- a/django/contrib/formtools/wizard/storage/base.py
+++ b/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 @@ class BaseStorage(object):
 
         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)
diff --git a/django/http/__init__.py b/django/http/__init__.py
index 12a11cface..ed4a23928f 100644
--- a/django/http/__init__.py
+++ b/django/http/__init__.py
@@ -193,7 +193,7 @@ class HttpRequest(object):
         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