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
c602054f
Commit
c602054f
authored
Dec 25, 2011
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Spec test display format: cherry-pick from '
4eaa43b5
'
Improved display format of spec tests and fixed partials typo.
parent
e06bed51
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
8 deletions
+33
-8
tests/test_spec.py
+33
-8
No files found.
tests/test_spec.py
View file @
c602054f
# coding: utf-8
"""
Tests the mustache spec test cases.
"""
import
glob
import
os.path
import
pystache
from
pystache
import
Loader
import
unittest
import
yaml
import
pystache
from
pystache
import
Loader
def
code_constructor
(
loader
,
node
):
value
=
loader
.
construct_mapping
(
node
)
return
eval
(
value
[
'python'
],
{})
...
...
@@ -17,7 +26,13 @@ specs = glob.glob(os.path.join(specs, '*.yml'))
class
MustacheSpec
(
unittest
.
TestCase
):
pass
def
buildTest
(
testData
,
spec
):
def
buildTest
(
testData
,
spec_filename
):
name
=
testData
[
'name'
]
description
=
testData
[
'desc'
]
test_name
=
"
%
s (
%
s)"
%
(
name
,
spec_filename
)
def
test
(
self
):
template
=
testData
[
'template'
]
partials
=
testData
.
has_key
(
'partials'
)
and
testData
[
'partials'
]
or
{}
...
...
@@ -32,19 +47,29 @@ def buildTest(testData, spec):
p
=
open
(
files
[
-
1
],
'w'
)
p
.
write
(
partials
[
key
])
p
.
close
()
self
.
assertEquals
(
pystache
.
render
(
template
,
data
),
expected
)
actual
=
pystache
.
render
(
template
,
data
)
.
encode
(
'utf-8'
)
message
=
"""
%
s
Template:
\"
""
%
s
\"
""
Expected:
%
s
Actual:
%
s"""
%
(
description
,
template
,
repr
(
expected
),
repr
(
actual
))
self
.
assertEquals
(
actual
,
expected
,
message
)
finally
:
[
os
.
remove
(
f
)
for
f
in
files
]
test
.
__doc__
=
testData
[
'desc'
]
test
.
__name__
=
'test
%
s (
%
s)'
%
(
testData
[
'name'
],
spec
)
# The name must begin with "test" for nosetests test discovery to work.
test
.
__name__
=
'test: "
%
s"'
%
test_name
return
test
for
spec
in
specs
:
name
=
os
.
path
.
basename
(
spec
)
.
replace
(
'.yml'
,
''
)
file_name
=
os
.
path
.
basename
(
spec
)
for
test
in
yaml
.
load
(
open
(
spec
))[
'tests'
]:
test
=
buildTest
(
test
,
name
)
test
=
buildTest
(
test
,
file_
name
)
setattr
(
MustacheSpec
,
test
.
__name__
,
test
)
if
__name__
==
'__main__'
:
...
...
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