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
c19e58c8
Commit
c19e58c8
authored
Feb 06, 2011
by
Pieter van de Bruggen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding tests for the Mustache spec.
parent
dba4ad89
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
0 deletions
+39
-0
tests/test_spec.py
+39
-0
No files found.
tests/test_spec.py
0 → 100644
View file @
c19e58c8
import
glob
import
os.path
import
pystache
import
unittest
import
yaml
def
code_constructor
(
loader
,
node
):
value
=
loader
.
construct_mapping
(
node
)
return
eval
(
value
[
'python'
],
{})
yaml
.
add_constructor
(
u'!code'
,
code_constructor
)
specs
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'..'
,
'ext'
,
'spec'
,
'specs'
)
specs
=
glob
.
glob
(
os
.
path
.
join
(
specs
,
'*.yml'
))
class
MustacheSpec
(
unittest
.
TestCase
):
pass
def
buildTest
(
testData
,
spec
):
def
test
(
self
):
template
=
testData
[
'template'
]
partials
=
testData
.
has_key
(
'partials'
)
and
test
[
'partials'
]
or
{}
expected
=
testData
[
'expected'
]
data
=
testData
[
'data'
]
self
.
assertEquals
(
pystache
.
render
(
template
,
data
),
expected
)
test
.
__doc__
=
testData
[
'desc'
]
test
.
__name__
=
'test
%
s (
%
s)'
%
(
testData
[
'name'
],
spec
)
return
test
for
spec
in
specs
:
name
=
os
.
path
.
basename
(
spec
)
.
replace
(
'.yml'
,
''
)
for
test
in
yaml
.
load
(
open
(
spec
))[
'tests'
]:
test
=
buildTest
(
test
,
name
)
setattr
(
MustacheSpec
,
test
.
__name__
,
test
)
if
__name__
==
'__main__'
:
unittest
.
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