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
51e31f57
Commit
51e31f57
authored
Apr 01, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed search_dirs from the SpecLoader constructor.
parent
81c6a9c4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
20 deletions
+7
-20
pystache/template_spec.py
+4
-8
tests/test_template_spec.py
+3
-12
No files found.
pystache/template_spec.py
View file @
51e31f57
...
...
@@ -122,8 +122,8 @@ class View(TemplateSpec):
return
renderer
.
render
(
template
,
self
.
context
)
# TODO:
get this class fully working with test cases, and then refactor
#
and replace the
View class.
# TODO:
add test cases for this class, and then refactor while replacing the
# View class.
class
SpecLoader
(
object
):
"""
...
...
@@ -131,15 +131,11 @@ class SpecLoader(object):
"""
def
__init__
(
self
,
search_dirs
=
None
,
loader
=
None
):
def
__init__
(
self
,
loader
=
None
):
if
loader
is
None
:
loader
=
Loader
()
if
search_dirs
is
None
:
search_dirs
=
[]
self
.
loader
=
loader
self
.
search_dirs
=
search_dirs
def
_find_relative
(
self
,
spec
):
"""
...
...
@@ -175,7 +171,7 @@ class SpecLoader(object):
if
dir_path
is
None
:
# Then we need to search for the path.
path
=
locator
.
find_object
(
spec
,
self
.
search_dirs
,
file_name
=
file_name
)
path
=
locator
.
find_object
(
spec
,
self
.
loader
.
search_dirs
,
file_name
=
file_name
)
else
:
obj_dir
=
locator
.
get_object_directory
(
spec
)
path
=
os
.
path
.
join
(
obj_dir
,
dir_path
,
file_name
)
...
...
tests/test_template_spec.py
View file @
51e31f57
...
...
@@ -150,20 +150,12 @@ class SpecLoaderTests(unittest.TestCase, AssertIsMixin, AssertStringMixin):
loader
=
custom
.
loader
self
.
assertEquals
(
loader
.
extension
,
'mustache'
)
self
.
assertEquals
(
loader
.
file_encoding
,
sys
.
getdefaultencoding
())
# TODO: finish testing the other Loader attributes.
to_unicode
=
loader
.
to_unicode
# Check search_dirs.
self
.
assertEquals
(
custom
.
search_dirs
,
[])
def
test_init__search_dirs
(
self
):
search_dirs
=
[
'a'
,
'b'
]
loader
=
SpecLoader
(
search_dirs
)
self
.
assertEquals
(
loader
.
search_dirs
,
[
'a'
,
'b'
])
def
test_init__loader
(
self
):
loader
=
Loader
()
custom
=
SpecLoader
(
[],
loader
=
loader
)
custom
=
SpecLoader
(
loader
=
loader
)
self
.
assertIs
(
custom
.
loader
,
loader
)
...
...
@@ -260,8 +252,7 @@ class TemplateSpecTests(unittest.TestCase):
# TODO: rename this method to _make_loader().
def
_make_locator
(
self
):
locator
=
SpecLoader
(
search_dirs
=
[
DATA_DIR
])
return
locator
return
SpecLoader
()
def
_assert_template_location
(
self
,
view
,
expected
):
locator
=
self
.
_make_locator
()
...
...
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