From 95b2bea86681ce89c1b103ab3b928a04f6dc2b6d Mon Sep 17 00:00:00 2001 From: Jonathan Ellenberger Date: Tue, 19 May 2015 14:08:20 -0400 Subject: [PATCH] Resolving Python 2/3 string encoding issues #14 --- tests/tests.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/tests.py b/tests/tests.py index 000aa85..f07ee94 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -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 @@ -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( ( @@ -368,7 +371,6 @@ def test_widget_javascript(self): response_content ) # Test required field with PPOI - """ self.assertInHTML( ( '
' @@ -403,9 +405,8 @@ def test_widget_javascript(self): ' type="hidden" value="0.5x0.5" />' '
' ), - str(response.content) + response_content ) - """ # Test required field no PPOI self.assertInHTML( ( @@ -423,7 +424,7 @@ def test_widget_javascript(self): ' type="hidden" value="0.5x0.5" />' '' ), - str(response.content) + response_content ) # Test optional image no PPOI self.assertInHTML( @@ -449,7 +450,7 @@ def test_widget_javascript(self): ' type="hidden" value="0.5x0.5" />' '' ), - str(response.content) + response_content ) # Test optional image with PPOI self.assertInHTML( @@ -494,7 +495,7 @@ def test_widget_javascript(self): ' name="optional_image_with_ppoi_1" type="hidden" value="1.0x1.0" />' '' ), - str(response.content) + response_content ) self.assertTrue( self.widget_test.image.field.storage.exists(