[Python-checkins] python/dist/src/Lib/test test_userdict.py,1.9,1.10

rhettinger@users.sourceforge.net rhettinger@users.sourceforge.net
Wed, 27 Nov 2002 00:29:13 -0800


Update of /cvsroot/python/python/dist/src/Lib/test
In directory sc8-pr-cvs1:/tmp/cvs-serv10075/test

Modified Files:
	test_userdict.py 
Log Message:
Bring UserDict in-sync with changes to dict.
  
Constructor accepts optional keyword arguments after a optional items list.
Add fromkeys() as an alternate constructor from an iterable over keys.
Expand related unittests.


Index: test_userdict.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_userdict.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** test_userdict.py	22 Nov 2002 00:07:40 -0000	1.9
--- test_userdict.py	27 Nov 2002 08:29:11 -0000	1.10
***************
*** 7,10 ****
--- 7,13 ----
  d1 = {"one": 1}
  d2 = {"one": 1, "two": 2}
+ d3 = {"one": 1, "two": 3, "three": 5}
+ d4 = {"one": None, "two": None}
+ d5 = {"one": 1, "two": 1}
  
  # Test constructors
***************
*** 22,25 ****
--- 25,38 ----
  verify(UserDict(one=1, two=2) == d2)            # keyword arg constructor
  verify(UserDict([('one',1), ('two',2)]) == d2)  # item sequence constructor
+ verify(UserDict(dict=[('one',1), ('two',2)]) == d2)
+ verify(UserDict([('one',1), ('two',2)], two=3, three=5) == d3) # both together
+ 
+ verify(UserDict.fromkeys('one two'.split()) == d4)  # alternate constructor
+ verify(UserDict().fromkeys('one two'.split()) == d4)
+ verify(UserDict.fromkeys('one two'.split(), 1) == d5)
+ verify(UserDict().fromkeys('one two'.split(), 1) == d5)
+ verify(u1.fromkeys('one two'.split()) is not u1)
+ verify(isinstance(u1.fromkeys('one two'.split()), UserDict))
+ verify(isinstance(u2.fromkeys('one two'.split()), IterableUserDict))
  
  # Test __repr__