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
4d8d41bb
Commit
4d8d41bb
authored
Mar 31, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed CustomLoader to SpecLoader.
parent
1542217e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
17 deletions
+16
-17
pystache/template_spec.py
+1
-2
tests/test_template_spec.py
+15
-15
No files found.
pystache/template_spec.py
View file @
4d8d41bb
...
...
@@ -119,10 +119,9 @@ class View(TemplateSpec):
return
renderer
.
render
(
template
,
self
.
context
)
# TODO: finalize this class's name.
# TODO: get this class fully working with test cases, and then refactor
# and replace the View class.
class
Custom
Loader
(
object
):
class
Spec
Loader
(
object
):
"""
Supports loading a custom-specified template.
...
...
tests/test_template_spec.py
View file @
4d8d41bb
...
...
@@ -16,7 +16,7 @@ from examples.inverted import Inverted, InvertedLists
from
pystache
import
TemplateSpec
as
Template
from
pystache
import
Renderer
from
pystache
import
View
from
pystache.template_spec
import
Custom
Loader
from
pystache.template_spec
import
Spec
Loader
from
pystache.locator
import
Locator
from
pystache.loader
import
Loader
from
.common
import
AssertIsMixin
...
...
@@ -136,15 +136,15 @@ class ViewTestCase(unittest.TestCase):
self
.
assertEquals
(
view
.
render
(),
"""one, two, three, empty list"""
)
class
Custom
LoaderTests
(
unittest
.
TestCase
,
AssertIsMixin
,
AssertStringMixin
):
class
Spec
LoaderTests
(
unittest
.
TestCase
,
AssertIsMixin
,
AssertStringMixin
):
"""
Tests template_spec.
Custom
Loader.
Tests template_spec.
Spec
Loader.
"""
def
test_init__defaults
(
self
):
custom
=
Custom
Loader
()
custom
=
Spec
Loader
()
# Check the loader attribute.
loader
=
custom
.
loader
...
...
@@ -157,13 +157,13 @@ class CustomLoaderTests(unittest.TestCase, AssertIsMixin, AssertStringMixin):
def
test_init__search_dirs
(
self
):
search_dirs
=
[
'a'
,
'b'
]
loader
=
Custom
Loader
(
search_dirs
)
loader
=
Spec
Loader
(
search_dirs
)
self
.
assertEquals
(
loader
.
search_dirs
,
[
'a'
,
'b'
])
def
test_init__loader
(
self
):
loader
=
Loader
()
custom
=
Custom
Loader
([],
loader
=
loader
)
custom
=
Spec
Loader
([],
loader
=
loader
)
self
.
assertIs
(
custom
.
loader
,
loader
)
...
...
@@ -179,7 +179,7 @@ class CustomLoaderTests(unittest.TestCase, AssertIsMixin, AssertStringMixin):
custom
=
Template
()
custom
.
template
=
"abc"
self
.
_assert_template
(
Custom
Loader
(),
custom
,
u"abc"
)
self
.
_assert_template
(
Spec
Loader
(),
custom
,
u"abc"
)
def
test_load__template__type_unicode
(
self
):
"""
...
...
@@ -189,7 +189,7 @@ class CustomLoaderTests(unittest.TestCase, AssertIsMixin, AssertStringMixin):
custom
=
Template
()
custom
.
template
=
u"abc"
self
.
_assert_template
(
Custom
Loader
(),
custom
,
u"abc"
)
self
.
_assert_template
(
Spec
Loader
(),
custom
,
u"abc"
)
def
test_load__template__unicode_non_ascii
(
self
):
"""
...
...
@@ -199,7 +199,7 @@ class CustomLoaderTests(unittest.TestCase, AssertIsMixin, AssertStringMixin):
custom
=
Template
()
custom
.
template
=
u"é"
self
.
_assert_template
(
Custom
Loader
(),
custom
,
u"é"
)
self
.
_assert_template
(
Spec
Loader
(),
custom
,
u"é"
)
def
test_load__template__with_template_encoding
(
self
):
"""
...
...
@@ -209,10 +209,10 @@ class CustomLoaderTests(unittest.TestCase, AssertIsMixin, AssertStringMixin):
custom
=
Template
()
custom
.
template
=
u'é'
.
encode
(
'utf-8'
)
self
.
assertRaises
(
UnicodeDecodeError
,
self
.
_assert_template
,
Custom
Loader
(),
custom
,
u'é'
)
self
.
assertRaises
(
UnicodeDecodeError
,
self
.
_assert_template
,
Spec
Loader
(),
custom
,
u'é'
)
custom
.
template_encoding
=
'utf-8'
self
.
_assert_template
(
Custom
Loader
(),
custom
,
u'é'
)
self
.
_assert_template
(
Spec
Loader
(),
custom
,
u'é'
)
# TODO: make this test complete.
def
test_load__template__correct_loader
(
self
):
...
...
@@ -221,7 +221,7 @@ class CustomLoaderTests(unittest.TestCase, AssertIsMixin, AssertStringMixin):
This test tests that the correct reader is called with the correct
arguments. This is a catch-all test to supplement the other
test cases. It tests
Custom
Loader.load() independent of reader.unicode()
test cases. It tests
Spec
Loader.load() independent of reader.unicode()
being implemented correctly (and tested).
"""
...
...
@@ -238,7 +238,7 @@ class CustomLoaderTests(unittest.TestCase, AssertIsMixin, AssertStringMixin):
return
u"foo"
loader
=
MockLoader
()
custom_loader
=
Custom
Loader
()
custom_loader
=
Spec
Loader
()
custom_loader
.
loader
=
loader
view
=
Template
()
...
...
@@ -251,7 +251,7 @@ class CustomLoaderTests(unittest.TestCase, AssertIsMixin, AssertStringMixin):
self
.
assertEquals
(
loader
.
encoding
,
"encoding-foo"
)
# TODO: migrate these tests into the
Custom
LoaderTests class.
# TODO: migrate these tests into the
Spec
LoaderTests class.
# TODO: rename the get_template() tests to test load().
# TODO: condense, reorganize, and rename the tests so that it is
# clear whether we have full test coverage (e.g. organized by
...
...
@@ -260,7 +260,7 @@ class TemplateSpecTests(unittest.TestCase):
# TODO: rename this method to _make_loader().
def
_make_locator
(
self
):
locator
=
Custom
Loader
(
search_dirs
=
[
DATA_DIR
])
locator
=
Spec
Loader
(
search_dirs
=
[
DATA_DIR
])
return
locator
def
_assert_template_location
(
self
,
view
,
expected
):
...
...
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