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
c2a31361
Commit
c2a31361
authored
Mar 24, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More progress on LoaderTests: template attribute.
parent
830eaa7b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
8 deletions
+43
-8
pystache/custom_template.py
+1
-1
tests/test_custom_template.py
+42
-7
No files found.
pystache/custom_template.py
View file @
c2a31361
...
...
@@ -123,7 +123,7 @@ class View(CustomizedTemplate):
class
Loader
(
object
):
"""
Supports loading
the template of a CustomizedTemplate instanc
e.
Supports loading
a custom-specified templat
e.
"""
...
...
tests/test_custom_template.py
View file @
c2a31361
...
...
@@ -139,7 +139,7 @@ class ViewTestCase(unittest.TestCase):
class
LoaderTests
(
unittest
.
TestCase
,
AssertIsMixin
,
AssertStringMixin
):
"""
Tests
the custom_template.Loader class
.
Tests
custom_template.Loader
.
"""
...
...
@@ -176,16 +176,51 @@ class LoaderTests(unittest.TestCase, AssertIsMixin, AssertStringMixin):
self
.
assertIs
(
loader
.
locator
,
locator
)
def
test_load__template__basic
(
self
):
def
_assert_template
(
self
,
loader
,
custom
,
expected
):
self
.
assertString
(
loader
.
load
(
custom
),
expected
)
def
test_load__template__type_str
(
self
):
"""
Test the template attribute.
Test the template attribute
: str string
.
"""
template
=
Template
()
template
.
template
=
"abc"
custom
=
Template
()
custom
.
template
=
"abc"
loader
=
Loader
()
self
.
assertString
(
loader
.
load
(
template
),
u"abc"
)
self
.
_assert_template
(
Loader
(),
custom
,
u"abc"
)
def
test_load__template__type_unicode
(
self
):
"""
Test the template attribute: unicode string.
"""
custom
=
Template
()
custom
.
template
=
u"abc"
self
.
_assert_template
(
Loader
(),
custom
,
u"abc"
)
def
test_load__template__unicode_non_ascii
(
self
):
"""
Test the template attribute: non-ascii unicode string.
"""
custom
=
Template
()
custom
.
template
=
u"é"
self
.
_assert_template
(
Loader
(),
custom
,
u"é"
)
def
test_load__template__with_template_encoding
(
self
):
"""
Test the template attribute: with template encoding attribute.
"""
custom
=
Template
()
custom
.
template
=
u'é'
.
encode
(
'utf-8'
)
self
.
assertRaises
(
UnicodeDecodeError
,
self
.
_assert_template
,
Loader
(),
custom
,
u'é'
)
custom
.
template_encoding
=
'utf-8'
self
.
_assert_template
(
Loader
(),
custom
,
u'é'
)
# TODO: migrate these tests into the LoaderTests class.
...
...
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