[Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.93,1.94
Guido van Rossum
gvanrossum@users.sourceforge.net
Thu, 25 Oct 2001 21:26:14 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv9797/Lib/test
Modified Files:
test_descr.py
Log Message:
Allow assignment to newinstance.__dict__.
Index: test_descr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v
retrieving revision 1.93
retrieving revision 1.94
diff -C2 -d -r1.93 -r1.94
*** test_descr.py 2001/10/22 21:45:25 1.93
--- test_descr.py 2001/10/26 04:26:12 1.94
***************
*** 2085,2088 ****
--- 2085,2113 ----
cant(list(), object)
+ def setdict():
+ if verbose: print "Testing __dict__ assignment..."
+ class C(object): pass
+ a = C()
+ a.__dict__ = {'b': 1}
+ vereq(a.b, 1)
+ def cant(x, dict):
+ try:
+ x.__dict__ = dict
+ except TypeError:
+ pass
+ else:
+ raise TestFailed, "shouldn't allow %r.__dict__ = %r" % (x, dict)
+ cant(a, None)
+ cant(a, [])
+ cant(a, 1)
+ try:
+ del a.__dict__
+ except TypeError:
+ pass
+ else:
+ raise TestFailed, "shouldn't allow del %r.__dict__" % (a)
+ # Classes don't allow __dict__ assignment
+ cant(C, {})
+
def pickles():
if verbose:
***************
*** 2392,2395 ****
--- 2417,2421 ----
descrdoc()
setclass()
+ setdict()
pickles()
copies()