pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python/cpython/commit/caaff8d95d750afb4d66b9caece087b191219eb7

test_dir(): Add tests for dir(i) where i is a module subclass. · python/cpython@caaff8d · GitHub
Skip to content

Commit caaff8d

Browse files
committed
test_dir(): Add tests for dir(i) where i is a module subclass.
1 parent 7b04946 commit caaff8d

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

Lib/test/test_descr.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,29 @@ def Amethod(self): pass
241241
a.amethod = lambda self: 3
242242
verify(interesting(dir(a)) == astuff + ['adata', 'amethod'])
243243

244+
# Try a module subclass.
245+
import sys
246+
class M(type(sys)):
247+
pass
248+
minstance = M()
249+
minstance.b = 2
250+
minstance.a = 1
251+
verify(dir(minstance) == ['a', 'b'])
252+
253+
class M2(M):
254+
def getdict(self):
255+
return "Not a dict!"
256+
__dict__ = property(getdict)
257+
258+
m2instance = M2()
259+
m2instance.b = 2
260+
m2instance.a = 1
261+
verify(m2instance.__dict__ == "Not a dict!")
262+
try:
263+
dir(m2instance)
264+
except TypeError:
265+
pass
266+
244267
binops = {
245268
'add': '+',
246269
'sub': '-',

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy