@@ -53,11 +53,11 @@ def parse_test_cases(
53
53
while i < len (p ) and p [i ].id != 'case' :
54
54
if p [i ].id == 'file' :
55
55
# Record an extra file needed for the test case.
56
- files .append ((os .path .join (base_path , p [i ].arg ),
56
+ files .append ((os .path .join (base_path , p [i ].arg or '' ),
57
57
'\n ' .join (p [i ].data )))
58
58
elif p [i ].id in ('builtins' , 'builtins_py2' ):
59
59
# Use a custom source file for the std module.
60
- mpath = os .path .join (os .path .dirname (path ), p [i ].arg )
60
+ mpath = os .path .join (os .path .dirname (path ), p [i ].arg or '' )
61
61
if p [i ].id == 'builtins' :
62
62
fnam = 'builtins.pyi'
63
63
else :
@@ -66,15 +66,17 @@ def parse_test_cases(
66
66
with open (mpath ) as f :
67
67
files .append ((os .path .join (base_path , fnam ), f .read ()))
68
68
elif p [i ].id == 'stale' :
69
- if p [i ].arg is None :
69
+ arg = p [i ].arg
70
+ if arg is None :
70
71
stale_modules = set ()
71
72
else :
72
- stale_modules = {item .strip () for item in p [ i ]. arg .split (',' )}
73
+ stale_modules = {item .strip () for item in arg .split (',' )}
73
74
elif p [i ].id == 'rechecked' :
74
- if p [i ].arg is None :
75
+ arg = p [i ].arg
76
+ if arg is None :
75
77
rechecked_modules = set ()
76
78
else :
77
- rechecked_modules = {item .strip () for item in p [ i ]. arg .split (',' )}
79
+ rechecked_modules = {item .strip () for item in arg .split (',' )}
78
80
elif p [i ].id == 'out' or p [i ].id == 'out1' :
79
81
tcout = p [i ].data
80
82
if native_sep and os .path .sep == '\\ ' :
@@ -95,7 +97,9 @@ def parse_test_cases(
95
97
# If the set of rechecked modules isn't specified, make it the same as the set of
96
98
# modules with a stale public interface.
97
99
rechecked_modules = stale_modules
98
- if stale_modules is not None and not stale_modules .issubset (rechecked_modules ):
100
+ if (stale_modules is not None
101
+ and rechecked_modules is not None
102
+ and not stale_modules .issubset (rechecked_modules )):
99
103
raise ValueError (
100
104
'Stale modules must be a subset of rechecked modules ({})' .format (path ))
101
105
@@ -225,15 +229,15 @@ class TestItem:
225
229
"""
226
230
227
231
id = ''
228
- arg = ''
232
+ arg = '' # type: Optional[str]
229
233
230
234
# Text data, array of 8-bit strings
231
235
data = None # type: List[str]
232
236
233
237
file = ''
234
238
line = 0 # Line number in file
235
239
236
- def __init__ (self , id : str , arg : str , data : List [str ], file : str ,
240
+ def __init__ (self , id : str , arg : Optional [ str ] , data : List [str ], file : str ,
237
241
line : int ) -> None :
238
242
self .id = id
239
243
self .arg = arg
@@ -248,8 +252,8 @@ def parse_test_data(l: List[str], fnam: str) -> List[TestItem]:
248
252
ret = [] # type: List[TestItem]
249
253
data = [] # type: List[str]
250
254
251
- id = None # type: str
252
- arg = None # type: str
255
+ id = None # type: Optional[ str]
256
+ arg = None # type: Optional[ str]
253
257
254
258
i = 0
255
259
i0 = 0
0 commit comments