[Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.34,1.35
Tim Peters
tim_one@users.sourceforge.net
Mon, 10 Sep 2001 16:12:16 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv27837/python/Lib/test
Modified Files:
test_descr.py
Log Message:
test_dir(): Add tests for dir(i) where i is a module subclass.
Index: test_descr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** test_descr.py 2001/09/10 21:28:20 1.34
--- test_descr.py 2001/09/10 23:12:14 1.35
***************
*** 242,245 ****
--- 242,268 ----
verify(interesting(dir(a)) == astuff + ['adata', 'amethod'])
+ # Try a module subclass.
+ import sys
+ class M(type(sys)):
+ pass
+ minstance = M()
+ minstance.b = 2
+ minstance.a = 1
+ verify(dir(minstance) == ['a', 'b'])
+
+ class M2(M):
+ def getdict(self):
+ return "Not a dict!"
+ __dict__ = property(getdict)
+
+ m2instance = M2()
+ m2instance.b = 2
+ m2instance.a = 1
+ verify(m2instance.__dict__ == "Not a dict!")
+ try:
+ dir(m2instance)
+ except TypeError:
+ pass
+
binops = {
'add': '+',