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
1ab8cf8c
Commit
1ab8cf8c
authored
Dec 21, 2011
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored the initial RenderEngine unit tests to use helper methods.
parent
35cf712f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
5 deletions
+32
-5
tests/test_renderengine.py
+32
-5
No files found.
tests/test_renderengine.py
View file @
1ab8cf8c
...
...
@@ -16,9 +16,36 @@ class RenderEngineTestCase(unittest.TestCase):
"""Test the RenderEngine class."""
def
_engine
(
self
,
partials
=
None
):
"""
Create and return a default RenderEngine for testing.
"""
load_template
=
None
to_unicode
=
unicode
escape
=
lambda
s
:
cgi
.
escape
(
to_unicode
(
s
))
literal
=
to_unicode
if
partials
is
not
None
:
load_template
=
lambda
key
:
partials
[
key
]
engine
=
RenderEngine
(
literal
=
literal
,
escape
=
escape
,
load_template
=
load_template
)
return
engine
def
_assert_render
(
self
,
engine
,
expected
,
template
,
*
context
):
if
engine
is
None
:
engine
=
self
.
_engine
()
context
=
Context
(
*
context
)
actual
=
engine
.
render
(
template
,
context
)
self
.
assertEquals
(
actual
,
expected
)
def
test_render
(
self
):
escape
=
lambda
s
:
cgi
.
escape
(
unicode
(
s
))
engine
=
RenderEngine
(
literal
=
unicode
,
escape
=
escape
)
context
=
Context
({
'person'
:
'Mom'
})
actual
=
engine
.
render
(
'Hi {{person}}'
,
context
)
self
.
assertEquals
(
actual
,
'Hi Mom'
)
self
.
_assert_render
(
None
,
'Hi Mom'
,
'Hi {{person}}'
,
{
'person'
:
'Mom'
})
def
test_render_with_partial
(
self
):
partials
=
{
'partial'
:
"{{person}}"
}
engine
=
self
.
_engine
(
partials
)
self
.
_assert_render
(
engine
,
'Hi Mom'
,
'Hi {{>partial}}'
,
{
'person'
:
'Mom'
})
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