Skip to content

Commit 1a81650

Browse files
[3.11] gh-115450: Fix direct invocation of test_desctut (GH-115451) (#115454)
gh-115450: Fix direct invocation of `test_desctut` (GH-115451) (cherry picked from commit ec8909a) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
1 parent c274fe7 commit 1a81650

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

Lib/test/test_descrtut.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@ def merge(self, other):
4040
Here's the new type at work:
4141
4242
>>> print(defaultdict) # show our type
43-
<class 'test.test_descrtut.defaultdict'>
43+
<class '%(modname)s.defaultdict'>
4444
>>> print(type(defaultdict)) # its metatype
4545
<class 'type'>
4646
>>> a = defaultdict(default=0.0) # create an instance
4747
>>> print(a) # show the instance
4848
{}
4949
>>> print(type(a)) # show its type
50-
<class 'test.test_descrtut.defaultdict'>
50+
<class '%(modname)s.defaultdict'>
5151
>>> print(a.__class__) # show its class
52-
<class 'test.test_descrtut.defaultdict'>
52+
<class '%(modname)s.defaultdict'>
5353
>>> print(type(a) is a.__class__) # its type is its class
5454
True
5555
>>> a[1] = 3.25 # modify the instance
@@ -100,7 +100,7 @@ def merge(self, other):
100100
>>> print(sortdict(a.__dict__))
101101
{'default': -1000, 'x1': 100, 'x2': 200}
102102
>>>
103-
"""
103+
""" % {'modname': __name__}
104104

105105
class defaultdict2(dict):
106106
__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)