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
aabb1c6b
Commit
aabb1c6b
authored
Apr 01, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename SpecLoader method to _find_relative().
parent
ed896eb9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
18 deletions
+17
-18
pystache/template_spec.py
+2
-3
tests/test_template_spec.py
+15
-15
No files found.
pystache/template_spec.py
View file @
aabb1c6b
...
...
@@ -141,8 +141,7 @@ class SpecLoader(object):
self
.
loader
=
loader
self
.
search_dirs
=
search_dirs
# TODO: make this private.
def
get_relative_template_location
(
self
,
view
):
def
_find_relative
(
self
,
view
):
"""
Return the relative template path as a (dir, file_name) pair.
...
...
@@ -169,7 +168,7 @@ class SpecLoader(object):
Find and return the path to the template associated to the instance.
"""
dir_path
,
file_name
=
self
.
get_relative_template_location
(
spec
)
dir_path
,
file_name
=
self
.
_find_relative
(
spec
)
# TODO: share code with the loader attribute here.
locator
=
Locator
(
extension
=
self
.
loader
.
extension
)
...
...
tests/test_template_spec.py
View file @
aabb1c6b
...
...
@@ -265,38 +265,38 @@ class TemplateSpecTests(unittest.TestCase):
def
_assert_template_location
(
self
,
view
,
expected
):
locator
=
self
.
_make_locator
()
actual
=
locator
.
get_relative_template_location
(
view
)
actual
=
locator
.
_find_relative
(
view
)
self
.
assertEquals
(
actual
,
expected
)
def
test_
get_relative_template_location
(
self
):
def
test_
find_relative
(
self
):
"""
Test
get_relative_template_location
(): default behavior (no attributes set).
Test
_find_relative
(): default behavior (no attributes set).
"""
view
=
SampleView
()
self
.
_assert_template_location
(
view
,
(
None
,
'sample_view.mustache'
))
def
test_
get_relative_template_location
__template_rel_path__file_name_only
(
self
):
def
test_
find_relative
__template_rel_path__file_name_only
(
self
):
"""
Test
get_relative_template_location
(): template_rel_path attribute.
Test
_find_relative
(): template_rel_path attribute.
"""
view
=
SampleView
()
view
.
template_rel_path
=
'template.txt'
self
.
_assert_template_location
(
view
,
(
''
,
'template.txt'
))
def
test_
get_relative_template_location
__template_rel_path__file_name_with_directory
(
self
):
def
test_
find_relative
__template_rel_path__file_name_with_directory
(
self
):
"""
Test
get_relative_template_location
(): template_rel_path attribute.
Test
_find_relative
(): template_rel_path attribute.
"""
view
=
SampleView
()
view
.
template_rel_path
=
'foo/bar/template.txt'
self
.
_assert_template_location
(
view
,
(
'foo/bar'
,
'template.txt'
))
def
test_
get_relative_template_location
__template_rel_directory
(
self
):
def
test_
find_relative
__template_rel_directory
(
self
):
"""
Test
get_relative_template_location
(): template_rel_directory attribute.
Test
_find_relative
(): template_rel_directory attribute.
"""
view
=
SampleView
()
...
...
@@ -304,18 +304,18 @@ class TemplateSpecTests(unittest.TestCase):
self
.
_assert_template_location
(
view
,
(
'foo'
,
'sample_view.mustache'
))
def
test_
get_relative_template_location
__template_name
(
self
):
def
test_
find_relative
__template_name
(
self
):
"""
Test
get_relative_template_location
(): template_name attribute.
Test
_find_relative
(): template_name attribute.
"""
view
=
SampleView
()
view
.
template_name
=
'new_name'
self
.
_assert_template_location
(
view
,
(
None
,
'new_name.mustache'
))
def
test_
get_relative_template_location
__template_extension
(
self
):
def
test_
find_relative
__template_extension
(
self
):
"""
Test
get_relative_template_location
(): template_extension attribute.
Test
_find_relative
(): template_extension attribute.
"""
view
=
SampleView
()
...
...
@@ -331,7 +331,7 @@ class TemplateSpecTests(unittest.TestCase):
view
=
SampleView
()
view
.
template_rel_path
=
'foo/bar.txt'
self
.
assertTrue
(
locator
.
get_relative_template_location
(
view
)[
0
]
is
not
None
)
self
.
assertTrue
(
locator
.
_find_relative
(
view
)[
0
]
is
not
None
)
actual
=
locator
.
_find
(
view
)
expected
=
os
.
path
.
abspath
(
os
.
path
.
join
(
DATA_DIR
,
'foo/bar.txt'
))
...
...
@@ -346,7 +346,7 @@ class TemplateSpecTests(unittest.TestCase):
locator
=
self
.
_make_locator
()
view
=
SampleView
()
self
.
assertTrue
(
locator
.
get_relative_template_location
(
view
)[
0
]
is
None
)
self
.
assertTrue
(
locator
.
_find_relative
(
view
)[
0
]
is
None
)
actual
=
locator
.
_find
(
view
)
expected
=
os
.
path
.
abspath
(
os
.
path
.
join
(
DATA_DIR
,
'sample_view.mustache'
))
...
...
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