[Python-checkins] CVS: python/dist/src/Lib/test test_funcattrs.py,1.3,1.4 test_opcodes.py,1.9,1.10

Moshe Zadka moshez@users.sourceforge.net
Sun, 28 Jan 2001 22:21:19 -0800


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

Modified Files:
	test_funcattrs.py test_opcodes.py 
Log Message:
The one thing I love more then writing code is deleting code.
* Removed func_hash and func_compare, so they can be treated as immutable
  content-less objects (address hash and comparison)
* Added tests to that affect to test_funcattrs (also testing func_code 
  is writable)
* Reverse meaning of tests in test_opcodes which checked identical code
  gets identical functions


Index: test_funcattrs.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_funcattrs.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** test_funcattrs.py	2001/01/19 19:55:12	1.3
--- test_funcattrs.py	2001/01/29 06:21:17	1.4
***************
*** 155,156 ****
--- 155,175 ----
  # core dump regression in funcobject.c
  del another.func_defaults
+ 
+ def foo():
+ 	pass
+ 
+ def bar():
+ 	pass
+ 
+ def temp():
+ 	print 1
+ 
+ if foo==bar: raise TestFailed
+ 
+ d={}
+ d[foo] = 1
+ 
+ foo.func_code = temp.func_code
+ 
+ d[foo]
+ 

Index: test_opcodes.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_opcodes.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -r1.9 -r1.10
*** test_opcodes.py	2000/12/12 23:11:42	1.9
--- test_opcodes.py	2001/01/29 06:21:17	1.10
***************
*** 51,60 ****
  try: raise AClass, b
  except BClass, v:
!     if v != b: raise TestFailed
! else: raise TestFailed
  
  try: raise b
  except AClass, v:
!     if v != b: raise TestFailed
  
  # not enough arguments
--- 51,60 ----
  try: raise AClass, b
  except BClass, v:
!     if v != b: raise TestFailed, "v!=b"
! else: raise TestFailed, "no exception"
  
  try: raise b
  except AClass, v:
!     if v != b: raise TestFailed, "v!=b AClass"
  
  # not enough arguments
***************
*** 65,69 ****
  except DClass, v:
      if not isinstance(v, DClass):
!         raise TestFailed
  
  print '2.3 comparing function objects'
--- 65,69 ----
  except DClass, v:
      if not isinstance(v, DClass):
!         raise TestFailed, "v not DClass"
  
  print '2.3 comparing function objects'
***************
*** 71,83 ****
  f = eval('lambda: None')
  g = eval('lambda: None')
! if f != g: raise TestFailed
  
  f = eval('lambda a: a')
  g = eval('lambda a: a')
! if f != g: raise TestFailed
  
  f = eval('lambda a=1: a')
  g = eval('lambda a=1: a')
! if f != g: raise TestFailed
  
  f = eval('lambda: 0')
--- 71,83 ----
  f = eval('lambda: None')
  g = eval('lambda: None')
! if f == g: raise TestFailed, "functions should not be same"
  
  f = eval('lambda a: a')
  g = eval('lambda a: a')
! if f == g: raise TestFailed, "functions should not be same"
  
  f = eval('lambda a=1: a')
  g = eval('lambda a=1: a')
! if f == g: raise TestFailed, "functions should not be same"
  
  f = eval('lambda: 0')