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

Guido van Rossum gvanrossum@users.sourceforge.net
Fri, 24 Aug 2001 08:24:26 -0700


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

Modified Files:
	test_descr.py 
Log Message:
Add a test for the new getset type.


Index: test_descr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** test_descr.py	2001/08/17 21:27:53	1.19
--- test_descr.py	2001/08/24 15:24:24	1.20
***************
*** 1070,1073 ****
--- 1070,1096 ----
      del r
  
+ def getsets():
+     if verbose: print "Testing getset..."
+     class C(object):
+         def getx(self):
+             return self.__x
+         def setx(self, value):
+             self.__x = value
+         def delx(self):
+             del self.__x
+         x = getset(getx, setx, delx)
+     a = C()
+     verify(not hasattr(a, "x"))
+     a.x = 42
+     verify(a._C__x == 42)
+     verify(a.x == 42)
+     del a.x
+     verify(not hasattr(a, "x"))
+     verify(not hasattr(a, "_C__x"))
+     C.x.__set__(a, 100)
+     verify(C.x.__get__(a) == 100)
+ ##    C.x.__set__(a)
+ ##    verify(not hasattr(a, "x"))
+ 
  def all():
      lists()
***************
*** 1099,1102 ****
--- 1122,1126 ----
      specials()
      weakrefs()
+     getsets()
  
  all()