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

Guido van Rossum gvanrossum@users.sourceforge.net
Fri, 20 Apr 2001 09:50:42 -0700


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

Modified Files:
	test_types.py 
Log Message:
Implement, test and document "key in dict" and "key not in dict".

I know some people don't like this -- if it's really controversial,
I'll take it out again.  (If it's only Alex Martelli who doesn't like
it, that doesn't count as "real controversial" though. :-)

That's why this is a separate checkin from the iterators stuff I'm
about to check in next.



Index: test_types.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_types.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -r1.19 -r1.20
*** test_types.py	2000/12/12 23:11:42	1.19
--- test_types.py	2001/04/20 16:50:40	1.20
***************
*** 222,225 ****
--- 222,227 ----
  if d.keys() != []: raise TestFailed, '{}.keys()'
  if d.has_key('a') != 0: raise TestFailed, '{}.has_key(\'a\')'
+ if ('a' in d) != 0: raise TestFailed, "'a' in {}"
+ if ('a' not in d) != 1: raise TestFailed, "'a' not in {}"
  if len(d) != 0: raise TestFailed, 'len({})'
  d = {'a': 1, 'b': 2}
***************
*** 230,233 ****
--- 232,237 ----
  if d.has_key('a') and d.has_key('b') and not d.has_key('c'): pass
  else: raise TestFailed, 'dict keys()'
+ if 'a' in d and 'b' in d and 'c' not in d: pass
+ else: raise TestFailed, 'dict keys() # in/not in version'
  if d['a'] != 1 or d['b'] != 2: raise TestFailed, 'dict item'
  d['c'] = 3