diff options
author | Raymond Hettinger <python@rcn.com> | 2008-02-06 00:07:11 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2008-02-06 00:07:11 (GMT) |
commit | f80680d8cdb7503c4b34e2c5a014d7c4f6e5817d (patch) | |
tree | c02f8db2179cce9a87317c373dcb733d6f2134c0 /Lib | |
parent | 554c8b856cbeb29f3fef0350846aef442832acac (diff) | |
download | cpython-f80680d8cdb7503c4b34e2c5a014d7c4f6e5817d.zip cpython-f80680d8cdb7503c4b34e2c5a014d7c4f6e5817d.tar.gz cpython-f80680d8cdb7503c4b34e2c5a014d7c4f6e5817d.tar.bz2 |
Migrate remaining tests from UserDict.UserDict to collections.UserDict.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/mapping_tests.py | 10 | ||||
-rw-r--r-- | Lib/test/test_builtin.py | 4 | ||||
-rw-r--r-- | Lib/test/test_cfgparser.py | 4 | ||||
-rw-r--r-- | Lib/test/test_dict.py | 6 | ||||
-rw-r--r-- | Lib/test/test_extcall.py | 2 | ||||
-rw-r--r-- | Lib/test/test_funcattrs.py | 2 |
6 files changed, 14 insertions, 14 deletions
diff --git a/Lib/test/mapping_tests.py b/Lib/test/mapping_tests.py index d595cc5..b8bbc9a 100644 --- a/Lib/test/mapping_tests.py +++ b/Lib/test/mapping_tests.py @@ -1,6 +1,6 @@ # 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) diff --git a/Lib/test/test_builtin.py b/Lib/test/test_builtin.py index 1b9edc0..b17133a 100644 --- a/Lib/test/test_builtin.py +++ b/Lib/test/test_builtin.py @@ -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." diff --git a/Lib/test/test_cfgparser.py b/Lib/test/test_cfgparser.py index 8822735..3ef82be 100644 --- a/Lib/test/test_cfgparser.py +++ b/Lib/test/test_cfgparser.py @@ -1,11 +1,11 @@ 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()) diff --git a/Lib/test/test_dict.py b/Lib/test/test_dict.py index 6a0b3c1..1997dc5 100644 --- a/Lib/test/test_dict.py +++ b/Lib/test/test_dict.py @@ -1,7 +1,7 @@ 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 diff --git a/Lib/test/test_extcall.py b/Lib/test/test_extcall.py index 611f4ab..2dc87b9 100644 --- a/Lib/test/test_extcall.py +++ b/Lib/test/test_extcall.py @@ -1,6 +1,6 @@ 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) diff --git a/Lib/test/test_funcattrs.py b/Lib/test/test_funcattrs.py index f2ab4f4..7385f96 100644 --- a/Lib/test/test_funcattrs.py +++ b/Lib/test/test_funcattrs.py @@ -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) |