summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-11-27 15:46:15 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-11-27 15:46:15 (GMT)
commitf51f713f303162572ded83d97772a1516d113c64 (patch)
tree3cebf6c3c2c3eb3993f3b75e930abb4b060b5646
parent8943ecfab20168f2b18bc477efb7671e32e91c24 (diff)
parenta86700ae875413e17a1a62306acead7908b6b064 (diff)
downloadcpython-f51f713f303162572ded83d97772a1516d113c64.zip
cpython-f51f713f303162572ded83d97772a1516d113c64.tar.gz
cpython-f51f713f303162572ded83d97772a1516d113c64.tar.bz2
Issue #22609: Revert changes in UserDict. They conflicted with existing tests.
-rw-r--r--Lib/collections/__init__.py9
-rw-r--r--Lib/test/test_collections.py21
2 files changed, 2 insertions, 28 deletions
diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py
index 605e4c5..7925af6 100644
--- a/Lib/collections/__init__.py
+++ b/Lib/collections/__init__.py
@@ -922,14 +922,7 @@ class ChainMap(MutableMapping):
class UserDict(MutableMapping):
# Start by filling-out the abstract methods
- def __init__(*args, **kwargs):
- if not args:
- raise TypeError("descriptor '__init__' of 'UserDict' object "
- "needs an argument")
- self, *args = args
- if len(args) > 1:
- raise TypeError('expected at most 1 arguments, got %d' % len(args))
- dict = args[0] if args else None
+ def __init__(self, dict=None, **kwargs):
self.data = {}
if dict is not None:
self.update(dict)
diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py
index 44cbe4f..db44d66 100644
--- a/Lib/test/test_collections.py
+++ b/Lib/test/test_collections.py
@@ -1639,24 +1639,6 @@ class SubclassMappingTests(mapping_tests.BasicTestMappingProtocol):
d = self._empty_mapping()
self.assertRaises(KeyError, d.popitem)
-class TestUserDict(unittest.TestCase):
-
- def test_init(self):
- self.assertEqual(list(UserDict(self=42).items()), [('self', 42)])
- self.assertEqual(list(UserDict(dict=42).items()), [('dict', 42)])
- self.assertEqual(list(UserDict(dict=None).items()), [('dict', None)])
- self.assertRaises(TypeError, UserDict, 42)
- self.assertRaises(TypeError, UserDict, (), ())
- self.assertRaises(TypeError, UserDict.__init__)
-
- def test_update(self):
- d = UserDict()
- d.update(self=42)
- self.assertEqual(list(d.items()), [('self', 42)])
- self.assertRaises(TypeError, UserDict().update, 42)
- self.assertRaises(TypeError, UserDict().update, {}, {})
- self.assertRaises(TypeError, UserDict.update)
-
################################################################################
### Run tests
@@ -1668,8 +1650,7 @@ def test_main(verbose=None):
NamedTupleDocs = doctest.DocTestSuite(module=collections)
test_classes = [TestNamedTuple, NamedTupleDocs, TestOneTrickPonyABCs,
TestCollectionABCs, TestCounter, TestChainMap,
- TestOrderedDict, GeneralMappingTests, SubclassMappingTests,
- TestUserDict,]
+ TestOrderedDict, GeneralMappingTests, SubclassMappingTests]
support.run_unittest(*test_classes)
support.run_doctest(collections, verbose)