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
e6cecddc
Commit
e6cecddc
authored
Dec 29, 2011
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a more substantial benchmarking test case.
parent
7bddf0c5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
3 deletions
+37
-3
tests/benchmark.py
+37
-3
No files found.
tests/benchmark.py
View file @
e6cecddc
...
...
@@ -19,10 +19,44 @@ import pystache
examples
=
[
# Test case: 1
(
"""
\
{{#person}}Hi {{name}}{{/person}}"""
,
(
"""{{#person}}Hi {{name}}{{/person}}"""
,
{
"person"
:
{
"name"
:
"Jon"
}},
"Hi Jon"
),
# Test case: 2
(
"""
\
<div class="comments">
<h3>{{header}}</h3>
<ul>
{{#comments}}<li class="comment">
<h5>{{name}}</h5><p>{{body}}</p>
</li>{{/comments}}
</ul>
</div>"""
,
{
'header'
:
"My Post Comments"
,
'comments'
:
[
{
'name'
:
"Joe"
,
'body'
:
"Thanks for this post!"
},
{
'name'
:
"Sam"
,
'body'
:
"Thanks for this post!"
},
{
'name'
:
"Heather"
,
'body'
:
"Thanks for this post!"
},
{
'name'
:
"Kathy"
,
'body'
:
"Thanks for this post!"
},
{
'name'
:
"George"
,
'body'
:
"Thanks for this post!"
}]},
"""
\
<div class="comments">
<h3>My Post Comments</h3>
<ul>
<li class="comment">
<h5>Joe</h5><p>Thanks for this post!</p>
</li><li class="comment">
<h5>Sam</h5><p>Thanks for this post!</p>
</li><li class="comment">
<h5>Heather</h5><p>Thanks for this post!</p>
</li><li class="comment">
<h5>Kathy</h5><p>Thanks for this post!</p>
</li><li class="comment">
<h5>George</h5><p>Thanks for this post!</p>
</li>
</ul>
</div>"""
),
]
...
...
@@ -33,7 +67,7 @@ def make_test_function(example):
def
test
():
actual
=
pystache
.
render
(
template
,
context
)
if
actual
!=
expected
:
raise
Exception
(
"Benchmark mismatch
"
)
raise
Exception
(
"Benchmark mismatch
:
\n
%
s
\n
*** != ***
\n
%
s"
%
(
expected
,
actual
)
)
return
test
...
...
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