Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
302bd589
Commit
302bd589
authored
Sep 13, 2004
by
Barry Warsaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for keyword arguments and combining mapping and keyword arguments.
parent
46b629c1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
0 deletions
+28
-0
Lib/test/test_pep292.py
Lib/test/test_pep292.py
+28
-0
No files found.
Lib/test/test_pep292.py
View file @
302bd589
...
...
@@ -118,6 +118,34 @@ class TestTemplate(unittest.TestCase):
d
=
dict
(
who
=
u't
\
xff
m'
,
what
=
u'f
\
xfe
\
f
ed'
)
self
.
assertEqual
(
s
.
substitute
(
d
),
u't
\
xff
m likes f
\
xfe
\
x0c
ed'
)
def
test_keyword_arguments
(
self
):
eq
=
self
.
assertEqual
s
=
Template
(
'$who likes $what'
)
eq
(
s
.
substitute
(
who
=
'tim'
,
what
=
'ham'
),
'tim likes ham'
)
eq
(
s
.
substitute
(
dict
(
who
=
'tim'
),
what
=
'ham'
),
'tim likes ham'
)
eq
(
s
.
substitute
(
dict
(
who
=
'fred'
,
what
=
'kung pao'
),
who
=
'tim'
,
what
=
'ham'
),
'tim likes ham'
)
s
=
Template
(
'the mapping is $mapping'
)
eq
(
s
.
substitute
(
dict
(
foo
=
'none'
),
mapping
=
'bozo'
),
'the mapping is bozo'
)
eq
(
s
.
substitute
(
dict
(
mapping
=
'one'
),
mapping
=
'two'
),
'the mapping is two'
)
def
test_keyword_arguments_safe
(
self
):
eq
=
self
.
assertEqual
s
=
Template
(
'$who likes $what'
)
eq
(
s
.
safe_substitute
(
who
=
'tim'
,
what
=
'ham'
),
'tim likes ham'
)
eq
(
s
.
safe_substitute
(
dict
(
who
=
'tim'
),
what
=
'ham'
),
'tim likes ham'
)
eq
(
s
.
safe_substitute
(
dict
(
who
=
'fred'
,
what
=
'kung pao'
),
who
=
'tim'
,
what
=
'ham'
),
'tim likes ham'
)
s
=
Template
(
'the mapping is $mapping'
)
eq
(
s
.
safe_substitute
(
dict
(
foo
=
'none'
),
mapping
=
'bozo'
),
'the mapping is bozo'
)
eq
(
s
.
safe_substitute
(
dict
(
mapping
=
'one'
),
mapping
=
'two'
),
'the mapping is two'
)
def
suite
():
suite
=
unittest
.
TestSuite
()
...
...
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