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
27a600e0
Commit
27a600e0
authored
Apr 21, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed a bug that affected the processing of ~lambdas.json (but not YAML).
parent
6e618797
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
13 deletions
+28
-13
pystache/tests/spectesting.py
+28
-13
No files found.
pystache/tests/spectesting.py
View file @
27a600e0
...
...
@@ -68,14 +68,8 @@ def get_spec_tests(spec_test_dir):
spec_paths
=
glob
.
glob
(
os
.
path
.
join
(
spec_test_dir
,
'*.
%
s'
%
file_extension
))
for
path
in
spec_paths
:
b
=
common
.
read
(
path
)
u
=
unicode
(
b
,
encoding
=
FILE_ENCODING
)
spec_data
=
parse
(
u
)
tests
=
spec_data
[
'tests'
]
for
data
in
tests
:
case
=
_deserialize_spec_test
(
data
,
path
)
cases
.
append
(
case
)
new_cases
=
_read_spec_tests
(
path
)
cases
.
extend
(
new_cases
)
# Store this as a value so that CheckSpecTestsFound is not checking
# a reference to cases that contains itself.
...
...
@@ -96,6 +90,24 @@ def get_spec_tests(spec_test_dir):
return
cases
def
_read_spec_tests
(
path
):
"""
Return a list of unittest.TestCase instances.
"""
b
=
common
.
read
(
path
)
u
=
unicode
(
b
,
encoding
=
FILE_ENCODING
)
spec_data
=
parse
(
u
)
tests
=
spec_data
[
'tests'
]
cases
=
[]
for
data
in
tests
:
case
=
_deserialize_spec_test
(
data
,
path
)
cases
.
append
(
case
)
return
cases
def
_deserialize_spec_test
(
data
,
file_path
):
"""
Return a unittest.TestCase instance representing a spec test.
...
...
@@ -105,7 +117,7 @@ def _deserialize_spec_test(data, file_path):
data: the dictionary of attributes for a single test.
"""
context
=
data
[
'data'
]
unconverted_
context
=
data
[
'data'
]
description
=
data
[
'desc'
]
# PyYAML seems to leave ASCII strings as byte strings.
expected
=
unicode
(
data
[
'expected'
])
...
...
@@ -116,11 +128,11 @@ def _deserialize_spec_test(data, file_path):
# Convert code strings to functions.
# TODO: make this section of code easier to understand.
new_
context
=
{}
for
key
,
val
in
context
.
iteritems
():
context
=
{}
for
key
,
val
in
unconverted_
context
.
iteritems
():
if
isinstance
(
val
,
dict
)
and
val
.
get
(
'__tag__'
)
==
'code'
:
val
=
eval
(
val
[
'python'
])
new_
context
[
key
]
=
val
context
[
key
]
=
val
test_case
=
_make_spec_test
(
expected
,
template
,
context
,
partials
,
description
,
test_name
,
file_path
)
...
...
@@ -219,7 +231,8 @@ class SpecTestBase(unittest.TestCase, AssertStringMixin):
def
escape
(
s
):
return
s
.
replace
(
"
%
"
,
"
%%
"
)
subs
=
[
repr
(
test_name
),
description
,
os
.
path
.
abspath
(
file_path
),
template
,
parser
.
__version__
,
str
(
parser
)]
subs
=
[
repr
(
test_name
),
description
,
os
.
path
.
abspath
(
file_path
),
template
,
repr
(
context
),
parser
.
__version__
,
str
(
parser
)]
subs
=
tuple
([
escape
(
sub
)
for
sub
in
subs
])
# We include the parsing module version info to help with troubleshooting
# yaml/json/simplejson issues.
...
...
@@ -229,6 +242,8 @@ class SpecTestBase(unittest.TestCase, AssertStringMixin):
Template:
\"
""
%
s
\"
""
Context:
%
s
%%
s
(using version
%
s of
%
s)
...
...
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