From b64aa813c89742f8cb589244eeba7cfc33957818 Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Wed, 31 Jul 2013 12:19:33 -0400 Subject: [PATCH] Make render_template mocking clearer --- common/lib/xmodule/xmodule/tests/test_xblock_wrappers.py | 6 +++--- lms/djangoapps/courseware/tests/__init__.py | 2 +- lms/djangoapps/courseware/tests/test_videoalpha_xml.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/common/lib/xmodule/xmodule/tests/test_xblock_wrappers.py b/common/lib/xmodule/xmodule/tests/test_xblock_wrappers.py index 39dc6afe0e..90ff209c7d 100644 --- a/common/lib/xmodule/xmodule/tests/test_xblock_wrappers.py +++ b/common/lib/xmodule/xmodule/tests/test_xblock_wrappers.py @@ -66,7 +66,7 @@ class TestXBlockWrapper(object): @property def leaf_module_runtime(self): runtime = Mock() - runtime.render_template = lambda *args, **kwargs: unicode((args, kwargs)) + runtime.render_template = lambda *args, **kwargs: u'{!r}, {!r}'.format(args, kwargs) runtime.anonymous_student_id = 'dummy_anonymous_student_id' runtime.open_ended_grading_interface = {} runtime.seed = 5 @@ -78,7 +78,7 @@ class TestXBlockWrapper(object): @property def leaf_descriptor_runtime(self): runtime = Mock() - runtime.render_template = lambda *args, **kwargs: unicode((args, kwargs)) + runtime.render_template = lambda *args, **kwargs: u'{!r}, {!r}'.format(args, kwargs) return runtime def leaf_descriptor(self, descriptor_cls): @@ -102,7 +102,7 @@ class TestXBlockWrapper(object): @property def container_descriptor_runtime(self): runtime = Mock() - runtime.render_template = lambda *args, **kwargs: unicode((args, kwargs)) + runtime.render_template = lambda *args, **kwargs: u'{!r}, {!r}'.format(args, kwargs) return runtime def container_descriptor(self, descriptor_cls): diff --git a/lms/djangoapps/courseware/tests/__init__.py b/lms/djangoapps/courseware/tests/__init__.py index 3169606a7b..cdb8bb8ea8 100644 --- a/lms/djangoapps/courseware/tests/__init__.py +++ b/lms/djangoapps/courseware/tests/__init__.py @@ -80,7 +80,7 @@ class BaseTestXmodule(ModuleStoreTestCase): self.runtime = get_test_system() # Allow us to assert that the template was called in the same way from # different code paths while maintaining the type returned by render_template - self.runtime.render_template = lambda template, context: unicode((template, sorted(context.items()))) + self.runtime.render_template = lambda template, context: u'{!r}, {!r}'.format(template, sorted(context.items())) model_data = {'location': self.item_descriptor.location} model_data.update(self.MODEL_DATA) diff --git a/lms/djangoapps/courseware/tests/test_videoalpha_xml.py b/lms/djangoapps/courseware/tests/test_videoalpha_xml.py index ae49be86dc..6df957a0e5 100644 --- a/lms/djangoapps/courseware/tests/test_videoalpha_xml.py +++ b/lms/djangoapps/courseware/tests/test_videoalpha_xml.py @@ -104,7 +104,7 @@ class VideoAlphaModuleUnitTest(unittest.TestCase): def test_videoalpha_constructor(self): """Make sure that all parameters extracted correclty from xml""" module = VideoAlphaFactory.create() - module.runtime.render_template = lambda template, context: unicode((template, sorted(context.items()))) + module.runtime.render_template = lambda template, context: u'{!r}, {!r}'.format(template, sorted(context.items())) fragment = module.runtime.render(module, None, 'student_view') expected_context = {