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
6209032b
Commit
6209032b
authored
Jan 02, 2012
by
Chris Jerdonek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Context.__repr__().
parent
35dc5e2b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
0 deletions
+33
-0
pystache/context.py
+13
-0
tests/test_context.py
+20
-0
No files found.
pystache/context.py
View file @
6209032b
...
...
@@ -112,6 +112,19 @@ class Context(object):
"""
self
.
_stack
=
list
(
items
)
def
__repr__
(
self
):
"""
Return a string representation of the instance.
For example--
>>> context = Context({'alpha': 'abc'}, {'numeric': 123})
>>> repr(context)
"Context({'alpha': 'abc'}, {'numeric': 123})"
"""
return
"
%
s
%
s"
%
(
self
.
__class__
.
__name__
,
tuple
(
self
.
_stack
))
@staticmethod
def
create
(
*
context
,
**
kwargs
):
"""
...
...
tests/test_context.py
View file @
6209032b
...
...
@@ -189,6 +189,26 @@ class ContextTests(TestCase):
"""
context
=
Context
({},
{},
{})
def
test__repr
(
self
):
context
=
Context
()
self
.
assertEquals
(
repr
(
context
),
'Context()'
)
context
=
Context
({
'foo'
:
'bar'
})
self
.
assertEquals
(
repr
(
context
),
"Context({'foo': 'bar'},)"
)
context
=
Context
({
'foo'
:
'bar'
},
{
'abc'
:
123
})
self
.
assertEquals
(
repr
(
context
),
"Context({'foo': 'bar'}, {'abc': 123})"
)
def
test__str
(
self
):
context
=
Context
()
self
.
assertEquals
(
str
(
context
),
'Context()'
)
context
=
Context
({
'foo'
:
'bar'
})
self
.
assertEquals
(
str
(
context
),
"Context({'foo': 'bar'},)"
)
context
=
Context
({
'foo'
:
'bar'
},
{
'abc'
:
123
})
self
.
assertEquals
(
str
(
context
),
"Context({'foo': 'bar'}, {'abc': 123})"
)
## Test the static create() method.
def
test_create__dictionary
(
self
):
...
...
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