Skip to content

Commit f7d1109

Browse files
[3.13] gh-133210: Fix test_inspect in --without-doc-strings mode (GH-133250) (#133263)
gh-133210: Fix `test_inspect` in `--without-doc-strings` mode (GH-133250) (cherry picked from commit 27e0114) Co-authored-by: sobolevn <[email protected]>
1 parent 90c786e commit f7d1109

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

Lib/test/test_inspect/test_inspect.py

+20-13
Original file line numberDiff line numberDiff line change
@@ -3602,9 +3602,10 @@ def m1d(*args, **kwargs):
36023602
int))
36033603

36043604
def test_signature_on_classmethod(self):
3605-
self.assertEqual(self.signature(classmethod),
3606-
((('function', ..., ..., "positional_only"),),
3607-
...))
3605+
if not support.MISSING_C_DOCSTRINGS:
3606+
self.assertEqual(self.signature(classmethod),
3607+
((('function', ..., ..., "positional_only"),),
3608+
...))
36083609

36093610
class Test:
36103611
@classmethod
@@ -3624,9 +3625,10 @@ def foo(cls, arg1, *, arg2=1):
36243625
...))
36253626

36263627
def test_signature_on_staticmethod(self):
3627-
self.assertEqual(self.signature(staticmethod),
3628-
((('function', ..., ..., "positional_only"),),
3629-
...))
3628+
if not support.MISSING_C_DOCSTRINGS:
3629+
self.assertEqual(self.signature(staticmethod),
3630+
((('function', ..., ..., "positional_only"),),
3631+
...))
36303632

36313633
class Test:
36323634
@staticmethod
@@ -4076,9 +4078,10 @@ def __init__(self, b):
40764078

40774079
self.assertEqual(C(3), 8)
40784080
self.assertEqual(C(3, 7), 1)
4079-
# BUG: Returns '<Signature (b)>'
4080-
with self.assertRaises(AssertionError):
4081-
self.assertEqual(self.signature(C), self.signature((0).__pow__))
4081+
if not support.MISSING_C_DOCSTRINGS:
4082+
# BUG: Returns '<Signature (b)>'
4083+
with self.assertRaises(AssertionError):
4084+
self.assertEqual(self.signature(C), self.signature((0).__pow__))
40824085

40834086
class CM(type):
40844087
def __new__(mcls, name, bases, dct, *, foo=1):
@@ -4478,7 +4481,8 @@ class C:
44784481
__call__ = (2).__pow__
44794482

44804483
self.assertEqual(C()(3), 8)
4481-
self.assertEqual(self.signature(C()), self.signature((0).__pow__))
4484+
if not support.MISSING_C_DOCSTRINGS:
4485+
self.assertEqual(self.signature(C()), self.signature((0).__pow__))
44824486

44834487
with self.subTest('ClassMethodDescriptorType'):
44844488
class C(dict):
@@ -4487,7 +4491,8 @@ class C(dict):
44874491
res = C()([1, 2], 3)
44884492
self.assertEqual(res, {1: 3, 2: 3})
44894493
self.assertEqual(type(res), C)
4490-
self.assertEqual(self.signature(C()), self.signature(dict.fromkeys))
4494+
if not support.MISSING_C_DOCSTRINGS:
4495+
self.assertEqual(self.signature(C()), self.signature(dict.fromkeys))
44914496

44924497
with self.subTest('MethodDescriptorType'):
44934498
class C(str):
@@ -4501,7 +4506,8 @@ class C(int):
45014506
__call__ = int.__pow__
45024507

45034508
self.assertEqual(C(2)(3), 8)
4504-
self.assertEqual(self.signature(C()), self.signature((0).__pow__))
4509+
if not support.MISSING_C_DOCSTRINGS:
4510+
self.assertEqual(self.signature(C()), self.signature((0).__pow__))
45054511

45064512
with self.subTest('MemberDescriptorType'):
45074513
class C:
@@ -4519,7 +4525,8 @@ class C:
45194525
def __call__(self, *args, **kwargs):
45204526
pass
45214527

4522-
self.assertEqual(self.signature(C), ((), ...))
4528+
if not support.MISSING_C_DOCSTRINGS:
4529+
self.assertEqual(self.signature(C), ((), ...))
45234530
self.assertEqual(self.signature(C()),
45244531
((('a', ..., ..., "positional_only"),
45254532
('b', ..., ..., "positional_or_keyword"),

0 commit comments

Comments
 (0)