summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-09-10 23:12:14 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-09-10 23:12:14 (GMT)
commitcaaff8d95d750afb4d66b9caece087b191219eb7 (patch)
tree6ee18c97284e9d880b882bd19210039de7e150b7 /Lib/test
parent7b0494635ba554601805eb8667401542124220f7 (diff)
downloadcpython-caaff8d95d750afb4d66b9caece087b191219eb7.zip
cpython-caaff8d95d750afb4d66b9caece087b191219eb7.tar.gz
cpython-caaff8d95d750afb4d66b9caece087b191219eb7.tar.bz2
test_dir(): Add tests for dir(i) where i is a module subclass.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_descr.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/test_descr.py b/Lib/test/test_descr.py
index 1ff9060..0bed675 100644
--- a/Lib/test/test_descr.py
+++ b/Lib/test/test_descr.py
@@ -241,6 +241,29 @@ def test_dir():
a.amethod = lambda self: 3
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': '+',
'sub': '-',