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
75da8604
Commit
75da8604
authored
Apr 29, 2011
by
Łukasz Langa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TestChainMap was not previously used. Minor corrections applied.
parent
17797a73
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
Lib/test/test_collections.py
Lib/test/test_collections.py
+8
-8
No files found.
Lib/test/test_collections.py
View file @
75da8604
...
...
@@ -10,7 +10,7 @@ from random import randrange, shuffle
import
keyword
import
re
import
sys
from
collections
import
_ChainMap
as
ChainMap
from
collections
import
_ChainMap
from
collections
import
Hashable
,
Iterable
,
Iterator
from
collections
import
Sized
,
Container
,
Callable
from
collections
import
Set
,
MutableSet
...
...
@@ -26,7 +26,7 @@ from collections import ByteString
class
TestChainMap
(
unittest
.
TestCase
):
def
test_basics
(
self
):
c
=
ChainMap
()
c
=
_
ChainMap
()
c
[
'a'
]
=
1
c
[
'b'
]
=
2
d
=
c
.
new_child
()
...
...
@@ -71,7 +71,7 @@ class TestChainMap(unittest.TestCase):
for
m1
,
m2
in
zip
(
d
.
maps
,
e
.
maps
):
self
.
assertIsNot
(
m1
,
m2
,
e
)
d
.
new_child
()
d
=
d
.
new_child
()
d
[
'b'
]
=
5
self
.
assertEqual
(
d
.
maps
,
[{
'b'
:
5
},
{
'c'
:
30
},
{
'a'
:
1
,
'b'
:
2
}])
self
.
assertEqual
(
d
.
parents
.
maps
,
[{
'c'
:
30
},
{
'a'
:
1
,
'b'
:
2
}])
# check parents
...
...
@@ -79,11 +79,11 @@ class TestChainMap(unittest.TestCase):
self
.
assertEqual
(
d
.
parents
[
'b'
],
2
)
# look beyond maps[0]
def
test_contructor
(
self
):
self
.
assertEqual
(
ChainedContext
().
maps
,
[{}])
# no-args --> one new dict
self
.
assertEqual
(
ChainMap
({
1
:
2
}).
maps
,
[{
1
:
2
}])
# 1 arg --> list
self
.
assertEqual
(
_ChainMap
().
maps
,
[{}])
# no-args --> one new dict
self
.
assertEqual
(
_
ChainMap
({
1
:
2
}).
maps
,
[{
1
:
2
}])
# 1 arg --> list
def
test_missing
(
self
):
class
DefaultChainMap
(
ChainMap
):
class
DefaultChainMap
(
_
ChainMap
):
def
__missing__
(
self
,
key
):
return
999
d
=
DefaultChainMap
(
dict
(
a
=
1
,
b
=
2
),
dict
(
b
=
20
,
c
=
30
))
...
...
@@ -100,7 +100,7 @@ class TestChainMap(unittest.TestCase):
d
.
popitem
()
def
test_dict_coercion
(
self
):
d
=
ChainMap
(
dict
(
a
=
1
,
b
=
2
),
dict
(
b
=
20
,
c
=
30
))
d
=
_
ChainMap
(
dict
(
a
=
1
,
b
=
2
),
dict
(
b
=
20
,
c
=
30
))
self
.
assertEqual
(
dict
(
d
),
dict
(
a
=
1
,
b
=
2
,
c
=
30
))
self
.
assertEqual
(
dict
(
d
.
items
()),
dict
(
a
=
1
,
b
=
2
,
c
=
30
))
...
...
@@ -1190,7 +1190,7 @@ import doctest, collections
def
test_main
(
verbose
=
None
):
NamedTupleDocs
=
doctest
.
DocTestSuite
(
module
=
collections
)
test_classes
=
[
TestNamedTuple
,
NamedTupleDocs
,
TestOneTrickPonyABCs
,
TestCollectionABCs
,
TestCounter
,
TestCollectionABCs
,
TestCounter
,
TestChainMap
,
TestOrderedDict
,
GeneralMappingTests
,
SubclassMappingTests
]
support
.
run_unittest
(
*
test_classes
)
support
.
run_doctest
(
collections
,
verbose
)
...
...
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