Skip to content

Commit

Permalink
Issue python#22609: Revert changes in UserDict. They conflicted with …
Browse files Browse the repository at this point in the history
…existing tests.
  • Loading branch information
serhiy-storchaka committed Nov 27, 2014
1 parent ae5cb21 commit a86700a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 28 deletions.
9 changes: 1 addition & 8 deletions Lib/collections/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -893,14 +893,7 @@ def clear(self):
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)
Expand Down
21 changes: 1 addition & 20 deletions Lib/test/test_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -1571,24 +1571,6 @@ def test_popitem(self):
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
Expand All @@ -1600,8 +1582,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)

Expand Down

0 comments on commit a86700a

Please sign in to comment.