Skip to content

Commit

Permalink
Resolving Python 2/3 string encoding issues
Browse files Browse the repository at this point in the history
  • Loading branch information
respondcreate committed May 19, 2015
1 parent e0f646a commit 95b2bea
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions tests/tests.py
Expand Up @@ -19,6 +19,7 @@
from django.test import Client, TestCase
from django.test.utils import override_settings
from django.utils._os import upath
from django.utils import six
from django.utils.six.moves import cPickle

from PIL import Image
Expand Down Expand Up @@ -356,8 +357,10 @@ def test_widget_javascript(self):
'/admin/tests/versatileimagewidgettestmodel/1/'
)
self.assertEqual(response.status_code, 200)
response_content = str(response.content)
print(response_content)
if six.PY2:
response_content = str(response.content)
else:
response_content = str(response.content, encoding='utf-8')
# Test that javascript loads correctly
self.assertInHTML(
(
Expand All @@ -368,7 +371,6 @@ def test_widget_javascript(self):
response_content
)
# Test required field with PPOI
"""
self.assertInHTML(
(
'<div class="versatileimagefield">'
Expand Down Expand Up @@ -403,9 +405,8 @@ def test_widget_javascript(self):
' type="hidden" value="0.5x0.5" />'
'</div>'
),
str(response.content)
response_content
)
"""
# Test required field no PPOI
self.assertInHTML(
(
Expand All @@ -423,7 +424,7 @@ def test_widget_javascript(self):
' type="hidden" value="0.5x0.5" />'
'</div>'
),
str(response.content)
response_content
)
# Test optional image no PPOI
self.assertInHTML(
Expand All @@ -449,7 +450,7 @@ def test_widget_javascript(self):
' type="hidden" value="0.5x0.5" />'
'</div>'
),
str(response.content)
response_content
)
# Test optional image with PPOI
self.assertInHTML(
Expand Down Expand Up @@ -494,7 +495,7 @@ def test_widget_javascript(self):
' name="optional_image_with_ppoi_1" type="hidden" value="1.0x1.0" />'
'</div>'
),
str(response.content)
response_content
)
self.assertTrue(
self.widget_test.image.field.storage.exists(
Expand Down

0 comments on commit 95b2bea

Please sign in to comment.