Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pystache_custom
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
pystache_custom
Commits
4af76cab
Commit
4af76cab
authored
Apr 07, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Another Python 3 unit test change.
parent
46fff9a4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
6 deletions
+16
-6
pystache/renderer.py
+3
-3
pystache/tests/test_renderer.py
+13
-3
No files found.
pystache/renderer.py
View file @
4af76cab
...
...
@@ -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
):
"""
...
...
pystache/tests/test_renderer.py
View file @
4af76cab
...
...
@@ -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
):
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment