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
b822c613
Commit
b822c613
authored
Dec 12, 2000
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added test for {}.popitem().
parent
ba6ab84e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
0 deletions
+24
-0
Lib/test/test_types.py
Lib/test/test_types.py
+24
-0
No files found.
Lib/test/test_types.py
View file @
b822c613
...
@@ -265,3 +265,27 @@ if d['key'][0] <> 3:
...
@@ -265,3 +265,27 @@ if d['key'][0] <> 3:
d
.
setdefault
(
'key'
,
[]).
append
(
4
)
d
.
setdefault
(
'key'
,
[]).
append
(
4
)
if
len
(
d
[
'key'
])
<>
2
:
if
len
(
d
[
'key'
])
<>
2
:
raise
TestFailed
,
'present {} setdefault, w/ 2nd arg'
raise
TestFailed
,
'present {} setdefault, w/ 2nd arg'
# dict.popitem()
for
copymode
in
-
1
,
+
1
:
# -1: b has same structure as a
# +1: b is a.copy()
for
log2size
in
range
(
12
):
size
=
2
**
log2size
a
=
{}
b
=
{}
for
i
in
range
(
size
):
a
[
`i`
]
=
i
if
copymode
<
0
:
b
[
`i`
]
=
i
if
copymode
>
0
:
b
=
a
.
copy
()
for
i
in
range
(
size
):
ka
,
va
=
ta
=
a
.
popitem
()
if
va
!=
int
(
ka
):
raise
TestFailed
,
"a.popitem: %s"
%
str
(
ta
)
kb
,
vb
=
tb
=
b
.
popitem
()
if
vb
!=
int
(
kb
):
raise
TestFailed
,
"b.popitem: %s"
%
str
(
tb
)
if
copymode
<
0
and
ta
!=
tb
:
raise
TestFailed
,
"a.popitem != b.popitem: %s, %s"
%
(
str
(
ta
),
str
(
tb
))
if
a
:
raise
TestFailed
,
'a not empty after popitems: %s'
%
str
(
a
)
if
b
:
raise
TestFailed
,
'b not empty after popitems: %s'
%
str
(
b
)
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