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
6ddc457d
Commit
6ddc457d
authored
Jul 23, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add unit tests for Loader.load_file() and Loader.load_name().
parent
796d2639
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
6 deletions
+19
-6
pystache/loader.py
+3
-5
pystache/tests/test_loader.py
+16
-1
No files found.
pystache/loader.py
View file @
6ddc457d
...
...
@@ -42,9 +42,9 @@ class Loader(object):
Arguments:
extension: the template file extension
. Pass False for no
extension (i.e. to use extensionless template files).
Defaults to the package default.
extension: the template file extension
, without the leading dot.
Pass False for no extension (e.g. to use extensionless template
files).
Defaults to the package default.
file_encoding: the name of the encoding to use when converting file
contents to unicode. Defaults to the package default.
...
...
@@ -119,7 +119,6 @@ class Loader(object):
return
self
.
unicode
(
b
,
encoding
)
# TODO: unit-test this method.
def
load_file
(
self
,
file_name
):
"""
Find and return the template with the given file name.
...
...
@@ -135,7 +134,6 @@ class Loader(object):
return
self
.
read
(
path
)
# TODO: unit-test this method.
def
load_name
(
self
,
name
):
"""
Find and return the template with the given template name.
...
...
pystache/tests/test_loader.py
View file @
6ddc457d
...
...
@@ -14,6 +14,10 @@ from pystache import defaults
from
pystache.loader
import
Loader
# We use the same directory as the locator tests for now.
LOADER_DATA_DIR
=
os
.
path
.
join
(
DATA_DIR
,
'locator'
)
class
LoaderTests
(
unittest
.
TestCase
,
AssertStringMixin
,
SetupDefaults
):
def
setUp
(
self
):
...
...
@@ -178,7 +182,7 @@ class LoaderTests(unittest.TestCase, AssertStringMixin, SetupDefaults):
actual
=
loader
.
read
(
path
,
encoding
=
'utf-8'
)
self
.
assertString
(
actual
,
u'non-ascii: é'
)
def
test_
loader
__to_unicode__attribute
(
self
):
def
test_
read
__to_unicode__attribute
(
self
):
"""
Test read(): to_unicode attribute respected.
...
...
@@ -192,3 +196,14 @@ class LoaderTests(unittest.TestCase, AssertStringMixin, SetupDefaults):
#actual = loader.read(path)
#self.assertString(actual, u'non-ascii: ')
def
test_load_file
(
self
):
loader
=
Loader
(
search_dirs
=
[
DATA_DIR
,
LOADER_DATA_DIR
])
template
=
loader
.
load_file
(
'template.txt'
)
self
.
assertEqual
(
template
,
'Test template file
\n
'
)
def
test_load_name
(
self
):
loader
=
Loader
(
search_dirs
=
[
DATA_DIR
,
LOADER_DATA_DIR
],
extension
=
'txt'
)
template
=
loader
.
load_name
(
'template'
)
self
.
assertEqual
(
template
,
'Test template file
\n
'
)
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