BOM-617 Fix test_static_replace test failures.

Update the tests around static_file code to use byte streams instead of
string streams for generating static content.  This is a fix to get
these tests passing on python 3.
This commit is contained in:
Feanil Patel
2019-09-18 11:08:25 -04:00
parent 530dadb1b0
commit ea49975a73
4 changed files with 11 additions and 8 deletions

View File

@@ -3,7 +3,7 @@
from __future__ import absolute_import, print_function
import re
from six import StringIO
from six import BytesIO
from six.moves.urllib.parse import parse_qsl, urlparse, urlunparse
import ddt
@@ -331,7 +331,7 @@ class CanonicalContentTest(SharedModuleStoreTestCase):
StaticContent: the StaticContent object for the created image
"""
new_image = Image.new('RGB', dimensions, color)
new_buf = StringIO()
new_buf = BytesIO()
new_image.save(new_buf, format='png')
new_buf.seek(0)
new_name = name.format(prefix)
@@ -355,7 +355,7 @@ class CanonicalContentTest(SharedModuleStoreTestCase):
StaticContent: the StaticContent object for the created content
"""
new_buf = StringIO('testingggggggggggg')
new_buf = BytesIO(b'testingggggggggggg')
new_name = name.format(prefix)
new_key = StaticContent.compute_location(cls.courses[prefix].id, new_name)
new_content = StaticContent(new_key, new_name, 'application/octet-stream', new_buf.getvalue(), locked=locked)