Skip to content

Commit ec8909a

Browse files
authored
gh-115450: Fix direct invocation of test_desctut (#115451)
1 parent 029ec91 commit ec8909a

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

Lib/test/test_descrtut.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,16 @@ def merge(self, other):
3939
Here's the new type at work:
4040
4141
>>> print(defaultdict) # show our type
42-
<class 'test.test_descrtut.defaultdict'>
42+
<class '%(modname)s.defaultdict'>
4343
>>> print(type(defaultdict)) # its metatype
4444
<class 'type'>
4545
>>> a = defaultdict(default=0.0) # create an instance
4646
>>> print(a) # show the instance
4747
{}
4848
>>> print(type(a)) # show its type
49-
<class 'test.test_descrtut.defaultdict'>
49+
<class '%(modname)s.defaultdict'>
5050
>>> print(a.__class__) # show its class
51-
<class 'test.test_descrtut.defaultdict'>
51+
<class '%(modname)s.defaultdict'>
5252
>>> print(type(a) is a.__class__) # its type is its class
5353
True
5454
>>> a[1] = 3.25 # modify the instance
@@ -99,7 +99,7 @@ def merge(self, other):
9999
>>> print(sortdict(a.__dict__))
100100
{'default': -1000, 'x1': 100, 'x2': 200}
101101
>>>
102-
"""
102+
""" % {'modname': __name__}
103103

104104
class defaultdict2(dict):
105105
__slots__ = ['default']
@@ -264,19 +264,19 @@ def merge(self, other):
264264
... print("classmethod", cls, y)
265265
266266
>>> C.foo(1)
267-
classmethod <class 'test.test_descrtut.C'> 1
267+
classmethod <class '%(modname)s.C'> 1
268268
>>> c = C()
269269
>>> c.foo(1)
270-
classmethod <class 'test.test_descrtut.C'> 1
270+
classmethod <class '%(modname)s.C'> 1
271271
272272
>>> class D(C):
273273
... pass
274274
275275
>>> D.foo(1)
276-
classmethod <class 'test.test_descrtut.D'> 1
276+
classmethod <class '%(modname)s.D'> 1
277277
>>> d = D()
278278
>>> d.foo(1)
279-
classmethod <class 'test.test_descrtut.D'> 1
279+
classmethod <class '%(modname)s.D'> 1
280280
281281
This prints "classmethod __main__.D 1" both times; in other words, the
282282
class passed as the first argument of foo() is the class involved in the
@@ -292,18 +292,18 @@ class passed as the first argument of foo() is the class involved in the
292292
293293
>>> E.foo(1)
294294
E.foo() called
295-
classmethod <class 'test.test_descrtut.C'> 1
295+
classmethod <class '%(modname)s.C'> 1
296296
>>> e = E()
297297
>>> e.foo(1)
298298
E.foo() called
299-
classmethod <class 'test.test_descrtut.C'> 1
299+
classmethod <class '%(modname)s.C'> 1
300300
301301
In this example, the call to C.foo() from E.foo() will see class C as its
302302
first argument, not class E. This is to be expected, since the call
303303
specifies the class C. But it stresses the difference between these class
304304
methods and methods defined in metaclasses (where an upcall to a metamethod
305305
would pass the target class as an explicit first argument).
306-
"""
306+
""" % {'modname': __name__}
307307

308308
test_5 = """
309309

0 commit comments

Comments
 (0)