[Python-checkins] CVS: python/dist/src/Lib/test test_types.py,1.13,1.14

Guido van Rossum python-dev@python.org
Tue, 8 Aug 2000 09:13:25 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory slayer.i.sourceforge.net:/tmp/cvs-serv4816

Modified Files:
	test_types.py 
Log Message:
Barry's patch to test the new setdefault() method.


Index: test_types.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_types.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -r1.13 -r1.14
*** test_types.py	2000/02/23 22:23:17	1.13
--- test_types.py	2000/08/08 16:13:23	1.14
***************
*** 254,255 ****
--- 254,267 ----
  if d.get('a') != 1: raise TestFailed, 'present dict get, no 2nd arg'
  if d.get('a', 3) != 1: raise TestFailed, 'present dict get, w/ 2nd arg'
+ # dict.setdefault()
+ d = {}
+ if d.setdefault('key0') <> None:
+ 	raise TestFailed, 'missing {} setdefault, no 2nd arg'
+ if d.setdefault('key0') <> None:
+ 	raise TestFailed, 'present {} setdefault, no 2nd arg'
+ d.setdefault('key', []).append(3)
+ if d['key'][0] <> 3:
+ 	raise TestFailed, 'missing {} setdefault, w/ 2nd arg'
+ d.setdefault('key', []).append(4)
+ if len(d['key']) <> 2:
+ 	raise TestFailed, 'present {} setdefault, w/ 2nd arg'