Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1bdd9b0

Browse files
committed
Test repair now that module.__init__ requires a name and initializes
__name__ and __doc__.
1 parent bdabecc commit 1bdd9b0

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

Lib/test/test_descr.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -342,17 +342,18 @@ def Amethod(self): pass
342342
import sys
343343
class M(type(sys)):
344344
pass
345-
minstance = M()
345+
minstance = M("m")
346346
minstance.b = 2
347347
minstance.a = 1
348-
vereq(dir(minstance), ['a', 'b'])
348+
names = [x for x in dir(minstance) if x not in ["__name__", "__doc__"]]
349+
vereq(names, ['a', 'b'])
349350

350351
class M2(M):
351352
def getdict(self):
352353
return "Not a dict!"
353354
__dict__ = property(getdict)
354355

355-
m2instance = M2()
356+
m2instance = M2("m2")
356357
m2instance.b = 2
357358
m2instance.a = 1
358359
vereq(m2instance.__dict__, "Not a dict!")
@@ -818,8 +819,8 @@ def pymods():
818819
import sys
819820
MT = type(sys)
820821
class MM(MT):
821-
def __init__(self):
822-
MT.__init__(self)
822+
def __init__(self, name):
823+
MT.__init__(self, name)
823824
def __getattribute__(self, name):
824825
log.append(("getattr", name))
825826
return MT.__getattribute__(self, name)
@@ -829,7 +830,7 @@ def __setattr__(self, name, value):
829830
def __delattr__(self, name):
830831
log.append(("delattr", name))
831832
MT.__delattr__(self, name)
832-
a = MM()
833+
a = MM("a")
833834
a.foo = 12
834835
x = a.foo
835836
del a.foo

0 commit comments

Comments
 (0)