BOM-90
Made all tests py3 compatible.
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
import codecs
|
||||
import glob
|
||||
import hashlib
|
||||
import io
|
||||
import itertools
|
||||
import json
|
||||
import logging
|
||||
@@ -623,7 +625,7 @@ class XMLModuleStore(ModuleStoreReadBase):
|
||||
if filepath.endswith('~'): # skip *~ files
|
||||
continue
|
||||
|
||||
with open(filepath) as f:
|
||||
with io.open(filepath) as f:
|
||||
try:
|
||||
if filepath.find('.json') != -1:
|
||||
# json file with json data content
|
||||
@@ -645,7 +647,7 @@ class XMLModuleStore(ModuleStoreReadBase):
|
||||
slug = os.path.splitext(os.path.basename(filepath))[0]
|
||||
loc = course_descriptor.scope_ids.usage_id.replace(category=category, name=slug)
|
||||
# html file with html data content
|
||||
html = f.read().decode('utf-8')
|
||||
html = f.read()
|
||||
try:
|
||||
module = system.load_item(loc)
|
||||
module.data = html
|
||||
|
||||
@@ -1121,7 +1121,7 @@ class XModuleDescriptorToXBlockMixin(object):
|
||||
Interpret the parsed XML in `node`, creating an XModuleDescriptor.
|
||||
"""
|
||||
# It'd be great to not reserialize and deserialize the xml
|
||||
xml = etree.tostring(node)
|
||||
xml = etree.tostring(node).decode('utf-8')
|
||||
block = cls.from_xml(xml, runtime, id_generator)
|
||||
return block
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ Signal handlers for course goals.
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
import six
|
||||
from django.db import models
|
||||
from django.dispatch import receiver
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ class AccessResponse(object):
|
||||
if has_access:
|
||||
assert error_code is None
|
||||
|
||||
def __nonzero__(self):
|
||||
def __bool__(self):
|
||||
"""
|
||||
Overrides bool().
|
||||
|
||||
@@ -52,6 +52,8 @@ class AccessResponse(object):
|
||||
"""
|
||||
return self.has_access
|
||||
|
||||
__nonzero__ = __bool__
|
||||
|
||||
def to_json(self):
|
||||
"""
|
||||
Creates a serializable JSON representation of an AccessResponse object.
|
||||
|
||||
@@ -254,13 +254,13 @@ class StaticTabDateTestCase(LoginEnrollmentTestCase, SharedModuleStoreTestCase):
|
||||
url = reverse('static_tab', args=[text_type(self.course.id), 'new_tab'])
|
||||
resp = self.client.get(url)
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
self.assertIn("OOGIE BLOOGIE", resp.content)
|
||||
self.assertIn("OOGIE BLOOGIE", resp.content.decode('utf-8'))
|
||||
|
||||
def test_anonymous_user(self):
|
||||
url = reverse('static_tab', args=[text_type(self.course.id), 'new_tab'])
|
||||
resp = self.client.get(url)
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
self.assertIn("OOGIE BLOOGIE", resp.content)
|
||||
self.assertIn("OOGIE BLOOGIE", resp.content.decode('utf-8'))
|
||||
|
||||
def test_invalid_course_key(self):
|
||||
self.setup_user()
|
||||
@@ -329,14 +329,14 @@ class StaticTabDateTestCaseXML(LoginEnrollmentTestCase, ModuleStoreTestCase):
|
||||
url = reverse('static_tab', args=[text_type(self.xml_course_key), self.xml_url])
|
||||
resp = self.client.get(url)
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
self.assertIn(self.xml_data, resp.content)
|
||||
self.assertIn(self.xml_data, resp.content.decode('utf-8'))
|
||||
|
||||
@patch.dict('django.conf.settings.FEATURES', {'DISABLE_START_DATES': False})
|
||||
def test_anonymous_user_xml(self):
|
||||
url = reverse('static_tab', args=[text_type(self.xml_course_key), self.xml_url])
|
||||
resp = self.client.get(url)
|
||||
self.assertEqual(resp.status_code, 200)
|
||||
self.assertIn(self.xml_data, resp.content)
|
||||
self.assertIn(self.xml_data, resp.content.decode('utf-8'))
|
||||
|
||||
|
||||
@patch.dict('django.conf.settings.FEATURES', {'ENTRANCE_EXAMS': True})
|
||||
|
||||
Reference in New Issue
Block a user