@@ -1186,7 +1186,7 @@ def test_getfullargspec_builtin_func_no_signature(self):
11861186
11871187 cls = _testcapi .DocStringNoSignatureTest
11881188 obj = _testcapi .DocStringNoSignatureTest ()
1189- for builtin , template in [
1189+ tests = [
11901190 (_testcapi .docstring_no_signature_noargs , meth_noargs ),
11911191 (_testcapi .docstring_no_signature_o , meth_o ),
11921192 (cls .meth_noargs , meth_self_noargs ),
@@ -1201,7 +1201,6 @@ def test_getfullargspec_builtin_func_no_signature(self):
12011201 (cls .meth_o_coexist , meth_self_o ),
12021202
12031203 (time .time , meth_noargs ),
1204- (stat .S_IMODE , meth_o ),
12051204 (str .lower , meth_self_noargs ),
12061205 ('' .lower , meth_self_noargs ),
12071206 (set .add , meth_self_o ),
@@ -1212,7 +1211,16 @@ def test_getfullargspec_builtin_func_no_signature(self):
12121211 (datetime .datetime .utcnow , meth_type_noargs ),
12131212 (dict .__dict__ ['__class_getitem__' ], meth_type_o ),
12141213 (dict .__class_getitem__ , meth_type_o ),
1215- ]:
1214+ ]
1215+ try :
1216+ import _stat
1217+ except ImportError :
1218+ # if the _stat extension is not available, stat.S_IMODE() is
1219+ # implemented in Python, not in C
1220+ pass
1221+ else :
1222+ tests .append ((stat .S_IMODE , meth_o ))
1223+ for builtin , template in tests :
12161224 with self .subTest (builtin ):
12171225 self .assertEqual (inspect .getfullargspec (builtin ),
12181226 inspect .getfullargspec (template ))
@@ -2934,7 +2942,7 @@ def test_signature_on_builtins_no_signature(self):
29342942
29352943 cls = _testcapi .DocStringNoSignatureTest
29362944 obj = _testcapi .DocStringNoSignatureTest ()
2937- for builtin , template in [
2945+ tests = [
29382946 (_testcapi .docstring_no_signature_noargs , meth_noargs ),
29392947 (_testcapi .docstring_no_signature_o , meth_o ),
29402948 (cls .meth_noargs , meth_self_noargs ),
@@ -2949,7 +2957,6 @@ def test_signature_on_builtins_no_signature(self):
29492957 (cls .meth_o_coexist , meth_self_o ),
29502958
29512959 (time .time , meth_noargs ),
2952- (stat .S_IMODE , meth_o ),
29532960 (str .lower , meth_self_noargs ),
29542961 ('' .lower , meth_noargs ),
29552962 (set .add , meth_self_o ),
@@ -2960,7 +2967,16 @@ def test_signature_on_builtins_no_signature(self):
29602967 (datetime .datetime .utcnow , meth_noargs ),
29612968 (dict .__dict__ ['__class_getitem__' ], meth_type_o ),
29622969 (dict .__class_getitem__ , meth_o ),
2963- ]:
2970+ ]
2971+ try :
2972+ import _stat
2973+ except ImportError :
2974+ # if the _stat extension is not available, stat.S_IMODE() is
2975+ # implemented in Python, not in C
2976+ pass
2977+ else :
2978+ tests .append ((stat .S_IMODE , meth_o ))
2979+ for builtin , template in tests :
29642980 with self .subTest (builtin ):
29652981 self .assertEqual (inspect .signature (builtin ),
29662982 inspect .signature (template ))
0 commit comments