Commit 4af76cab by Chris Jerdonek

Another Python 3 unit test change.

parent 46fff9a4
......@@ -160,9 +160,9 @@ class Renderer(object):
"""
return unicode(self.escape(self._to_unicode_soft(s)))
def unicode(self, s, encoding=None):
def unicode(self, b, encoding=None):
"""
Convert a string to unicode, using string_encoding and decode_errors.
Convert a byte string to unicode, using string_encoding and decode_errors.
Raises:
......@@ -178,7 +178,7 @@ class Renderer(object):
# TODO: Wrap UnicodeDecodeErrors with a message about setting
# the string_encoding and decode_errors attributes.
return unicode(s, encoding, self.decode_errors)
return unicode(b, encoding, self.decode_errors)
def _make_loader(self):
"""
......
......@@ -393,6 +393,14 @@ class Renderer_MakeRenderEngineTests(unittest.TestCase):
"""
def _make_renderer(self):
"""
Return a default Renderer instance for testing purposes.
"""
renderer = Renderer(string_encoding='ascii', file_encoding='ascii')
return renderer
## Test the engine's load_partial attribute.
def test__load_partial__returns_unicode(self):
......@@ -442,13 +450,15 @@ class Renderer_MakeRenderEngineTests(unittest.TestCase):
Test that literal uses the renderer's unicode function.
"""
renderer = Renderer()
renderer.unicode = lambda s: s.upper()
renderer = self._make_renderer()
# This function
renderer.unicode = lambda b: unicode(b, encoding='ascii').upper()
engine = renderer._make_render_engine()
literal = engine.literal
self.assertEqual(literal("foo"), "FOO")
b = u"foo".encode("ascii")
self.assertEqual(literal(b), "FOO")
def test__literal__handles_unicode(self):
"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment