@@ -1186,7 +1186,7 @@ def test_getfullargspec_builtin_func_no_signature(self):
1186
1186
1187
1187
cls = _testcapi .DocStringNoSignatureTest
1188
1188
obj = _testcapi .DocStringNoSignatureTest ()
1189
- for builtin , template in [
1189
+ tests = [
1190
1190
(_testcapi .docstring_no_signature_noargs , meth_noargs ),
1191
1191
(_testcapi .docstring_no_signature_o , meth_o ),
1192
1192
(cls .meth_noargs , meth_self_noargs ),
@@ -1201,7 +1201,6 @@ def test_getfullargspec_builtin_func_no_signature(self):
1201
1201
(cls .meth_o_coexist , meth_self_o ),
1202
1202
1203
1203
(time .time , meth_noargs ),
1204
- (stat .S_IMODE , meth_o ),
1205
1204
(str .lower , meth_self_noargs ),
1206
1205
('' .lower , meth_self_noargs ),
1207
1206
(set .add , meth_self_o ),
@@ -1212,7 +1211,16 @@ def test_getfullargspec_builtin_func_no_signature(self):
1212
1211
(datetime .datetime .utcnow , meth_type_noargs ),
1213
1212
(dict .__dict__ ['__class_getitem__' ], meth_type_o ),
1214
1213
(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 :
1216
1224
with self .subTest (builtin ):
1217
1225
self .assertEqual (inspect .getfullargspec (builtin ),
1218
1226
inspect .getfullargspec (template ))
@@ -2934,7 +2942,7 @@ def test_signature_on_builtins_no_signature(self):
2934
2942
2935
2943
cls = _testcapi .DocStringNoSignatureTest
2936
2944
obj = _testcapi .DocStringNoSignatureTest ()
2937
- for builtin , template in [
2945
+ tests = [
2938
2946
(_testcapi .docstring_no_signature_noargs , meth_noargs ),
2939
2947
(_testcapi .docstring_no_signature_o , meth_o ),
2940
2948
(cls .meth_noargs , meth_self_noargs ),
@@ -2949,7 +2957,6 @@ def test_signature_on_builtins_no_signature(self):
2949
2957
(cls .meth_o_coexist , meth_self_o ),
2950
2958
2951
2959
(time .time , meth_noargs ),
2952
- (stat .S_IMODE , meth_o ),
2953
2960
(str .lower , meth_self_noargs ),
2954
2961
('' .lower , meth_noargs ),
2955
2962
(set .add , meth_self_o ),
@@ -2960,7 +2967,16 @@ def test_signature_on_builtins_no_signature(self):
2960
2967
(datetime .datetime .utcnow , meth_noargs ),
2961
2968
(dict .__dict__ ['__class_getitem__' ], meth_type_o ),
2962
2969
(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 :
2964
2980
with self .subTest (builtin ):
2965
2981
self .assertEqual (inspect .signature (builtin ),
2966
2982
inspect .signature (template ))
0 commit comments