File tree Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -288,26 +288,33 @@ class DirectoryTestCase(ASTTestCase):
288
288
test_directories = (lib_dir , lib_dir / "test" )
289
289
skip_files = {"test_fstring.py" }
290
290
291
- @functools .cached_property
292
- def files_to_test (self ):
293
- # bpo-31174: Use cached_property to store the names sample
294
- # to always test the same files. It prevents false alarms
295
- # when hunting reference leaks.
291
+ _files_to_test = None
292
+
293
+ @classmethod
294
+ def files_to_test (cls ):
295
+
296
+ if cls ._files_to_test is not None :
297
+ return cls ._files_to_test
296
298
297
299
items = [
298
300
item .resolve ()
299
- for directory in self .test_directories
301
+ for directory in cls .test_directories
300
302
for item in directory .glob ("*.py" )
301
303
if not item .name .startswith ("bad" )
302
304
]
303
305
304
306
# Test limited subset of files unless the 'cpu' resource is specified.
305
307
if not test .support .is_resource_enabled ("cpu" ):
306
308
items = random .sample (items , 10 )
309
+
310
+ # bpo-31174: Store the names sample to always test the same files.
311
+ # It prevents false alarms when hunting reference leaks.
312
+ cls ._files_to_test = items
313
+
307
314
return items
308
315
309
316
def test_files (self ):
310
- for item in self .files_to_test :
317
+ for item in self .files_to_test () :
311
318
if test .support .verbose :
312
319
print (f"Testing { item .absolute ()} " )
313
320
You can’t perform that action at this time.
0 commit comments