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
f80680d8
Commit
f80680d8
authored
Feb 06, 2008
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate remaining tests from UserDict.UserDict to collections.UserDict.
parent
554c8b85
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
14 additions
and
14 deletions
+14
-14
Lib/test/mapping_tests.py
Lib/test/mapping_tests.py
+5
-5
Lib/test/test_builtin.py
Lib/test/test_builtin.py
+2
-2
Lib/test/test_cfgparser.py
Lib/test/test_cfgparser.py
+2
-2
Lib/test/test_dict.py
Lib/test/test_dict.py
+3
-3
Lib/test/test_extcall.py
Lib/test/test_extcall.py
+1
-1
Lib/test/test_funcattrs.py
Lib/test/test_funcattrs.py
+1
-1
No files found.
Lib/test/mapping_tests.py
View file @
f80680d8
# tests common to dict and UserDict
import
unittest
import
UserDict
import
collections
class
BasicTestMappingProtocol
(
unittest
.
TestCase
):
...
...
@@ -438,11 +438,11 @@ class TestMappingProtocol(BasicTestMappingProtocol):
# self.assert_(type(dictlike.fromkeys('a')) is dictlike)
class
mydict
(
self
.
type2test
):
def
__new__
(
cls
):
return
UserDict
.
UserDict
()
return
collections
.
UserDict
()
ud
=
mydict
.
fromkeys
(
'ab'
)
self
.
assertEqual
(
ud
,
{
'a'
:
None
,
'b'
:
None
})
# FIXME: the following won't work with UserDict, because it's an old style class
# self.assert_(isinstance(ud,
UserDict
.UserDict))
# self.assert_(isinstance(ud,
collections
.UserDict))
self
.
assertRaises
(
TypeError
,
dict
.
fromkeys
)
class
Exc
(
Exception
):
pass
...
...
@@ -574,10 +574,10 @@ class TestHashMappingProtocol(TestMappingProtocol):
TestMappingProtocol
.
test_fromkeys
(
self
)
class
mydict
(
self
.
type2test
):
def
__new__
(
cls
):
return
UserDict
.
UserDict
()
return
collections
.
UserDict
()
ud
=
mydict
.
fromkeys
(
'ab'
)
self
.
assertEqual
(
ud
,
{
'a'
:
None
,
'b'
:
None
})
self
.
assert_
(
isinstance
(
ud
,
UserDict
.
UserDict
))
self
.
assert_
(
isinstance
(
ud
,
collections
.
UserDict
))
def
test_pop
(
self
):
TestMappingProtocol
.
test_pop
(
self
)
...
...
Lib/test/test_builtin.py
View file @
f80680d8
...
...
@@ -5,7 +5,7 @@ from test.test_support import fcmp, TESTFN, unlink, run_unittest, \
run_with_locale
from
operator
import
neg
import
sys
,
warnings
,
random
,
UserDict
,
io
,
rational
import
sys
,
warnings
,
random
,
collections
,
io
,
rational
warnings
.
filterwarnings
(
"ignore"
,
"hex../oct.. of negative int"
,
FutureWarning
,
__name__
)
warnings
.
filterwarnings
(
"ignore"
,
"integer argument expected"
,
...
...
@@ -400,7 +400,7 @@ class BuiltinTest(unittest.TestCase):
# Verify locals stores (used by list comps)
eval
(
'[locals() for i in (2,3)]'
,
g
,
d
)
eval
(
'[locals() for i in (2,3)]'
,
g
,
UserDict
.
UserDict
())
eval
(
'[locals() for i in (2,3)]'
,
g
,
collections
.
UserDict
())
class
SpreadSheet
:
"Sample application showing nested, calculated lookups."
...
...
Lib/test/test_cfgparser.py
View file @
f80680d8
import
ConfigParser
import
io
import
unittest
import
UserDict
import
collections
from
test
import
test_support
class
SortedDict
(
UserDict
.
UserDict
):
class
SortedDict
(
collections
.
UserDict
):
def
items
(
self
):
return
sorted
(
self
.
data
.
items
())
...
...
Lib/test/test_dict.py
View file @
f80680d8
import
unittest
from
test
import
test_support
import
sys
,
UserDict
,
random
,
string
import
sys
,
collections
,
random
,
string
class
DictTest
(
unittest
.
TestCase
):
...
...
@@ -209,10 +209,10 @@ class DictTest(unittest.TestCase):
self
.
assert_
(
type
(
dictlike
().
fromkeys
(
'a'
))
is
dictlike
)
class
mydict
(
dict
):
def
__new__
(
cls
):
return
UserDict
.
UserDict
()
return
collections
.
UserDict
()
ud
=
mydict
.
fromkeys
(
'ab'
)
self
.
assertEqual
(
ud
,
{
'a'
:
None
,
'b'
:
None
})
self
.
assert_
(
isinstance
(
ud
,
UserDict
.
UserDict
))
self
.
assert_
(
isinstance
(
ud
,
collections
.
UserDict
))
self
.
assertRaises
(
TypeError
,
dict
.
fromkeys
)
class
Exc
(
Exception
):
pass
...
...
Lib/test/test_extcall.py
View file @
f80680d8
from
test.test_support
import
verify
,
verbose
,
TestFailed
,
sortdict
from
UserList
import
UserList
from
UserDict
import
UserDict
from
collections
import
UserDict
def
e
(
a
,
b
):
print
(
a
,
b
)
...
...
Lib/test/test_funcattrs.py
View file @
f80680d8
...
...
@@ -175,7 +175,7 @@ class ArbitraryFunctionAttrTest(FuncAttrsTest):
class
FunctionDictsTest
(
FuncAttrsTest
):
def
test_setting_dict_to_invalid
(
self
):
self
.
cannot_set_attr
(
self
.
b
,
'__dict__'
,
None
,
TypeError
)
from
UserDict
import
UserDict
from
collections
import
UserDict
d
=
UserDict
({
'known_attr'
:
7
})
self
.
cannot_set_attr
(
self
.
fi
.
a
.
__func__
,
'__dict__'
,
d
,
TypeError
)
...
...
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