Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
cython
Commits
6db16689
Commit
6db16689
authored
Apr 01, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
extended test cases
parent
a0ede829
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
0 deletions
+28
-0
tests/run/dict_get.pyx
tests/run/dict_get.pyx
+19
-0
tests/run/dict_getitem.pyx
tests/run/dict_getitem.pyx
+9
-0
No files found.
tests/run/dict_get.pyx
View file @
6db16689
cimport
cython
@
cython
.
test_assert_path_exists
(
"//PythonCapiCallNode"
)
@
cython
.
test_fail_if_path_exists
(
"//AttributeNode"
)
def
get
(
dict
d
,
key
):
"""
>>> d = { 1: 10 }
...
...
@@ -38,6 +43,9 @@ def get(dict d, key):
"""
return
d
.
get
(
key
)
@
cython
.
test_assert_path_exists
(
"//PythonCapiCallNode"
)
@
cython
.
test_fail_if_path_exists
(
"//AttributeNode"
)
def
get_default
(
dict
d
,
key
,
default
):
"""
>>> d = { 1: 10 }
...
...
@@ -69,3 +77,14 @@ def get_default(dict d, key, default):
ValueError
"""
return
d
.
get
(
key
,
default
)
@
cython
.
test_assert_path_exists
(
"//PythonCapiCallNode"
)
@
cython
.
test_fail_if_path_exists
(
"//AttributeNode"
)
def
get_in_condition
(
dict
d
,
key
,
expected_result
):
"""
>>> d = dict(a=1, b=2)
>>> getitem_in_condition(d, 'a', 1)
True
"""
return
d
.
get
(
key
)
is
expected_result
tests/run/dict_getitem.pyx
View file @
6db16689
...
...
@@ -32,3 +32,12 @@ def test(dict d, index):
cdef
class
Subscriptable
:
def
__getitem__
(
self
,
key
):
return
key
def
getitem_in_condition
(
dict
d
,
key
,
expected_result
):
"""
>>> d = dict(a=1, b=2)
>>> getitem_in_condition(d, 'a', 1)
True
"""
return
d
[
key
]
is
expected_result
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