Commit 8d54f517 authored by Tim Peters's avatar Tim Peters

test_dir(): Add tests for dir(i) where i is a module subclass.

parent e56a00c5
......@@ -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': '-',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment