diff options
author | Pablo Galindo <Pablogsal@gmail.com> | 2019-12-09 17:57:50 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-09 17:57:50 (GMT) |
commit | ac229116a34a679511c20bfeca167cc6a9df9807 (patch) | |
tree | e2d034f48d23439947774a2090ee3969b55df568 /Lib/test/test_unparse.py | |
parent | c18b805ac6a2d22176240ca93982fa1fb6559ec7 (diff) | |
download | cpython-ac229116a34a679511c20bfeca167cc6a9df9807.zip cpython-ac229116a34a679511c20bfeca167cc6a9df9807.tar.gz cpython-ac229116a34a679511c20bfeca167cc6a9df9807.tar.bz2 |
bpo-39003: Make sure all test are the same when using -R in test_unparse (GH-17537)
Diffstat (limited to 'Lib/test/test_unparse.py')
-rw-r--r-- | Lib/test/test_unparse.py | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/Lib/test/test_unparse.py b/Lib/test/test_unparse.py index 9197c8a..9611026 100644 --- a/Lib/test/test_unparse.py +++ b/Lib/test/test_unparse.py @@ -288,15 +288,17 @@ class DirectoryTestCase(ASTTestCase): test_directories = (lib_dir, lib_dir / "test") skip_files = {"test_fstring.py"} - @functools.cached_property - def files_to_test(self): - # bpo-31174: Use cached_property to store the names sample - # to always test the same files. It prevents false alarms - # when hunting reference leaks. + _files_to_test = None + + @classmethod + def files_to_test(cls): + + if cls._files_to_test is not None: + return cls._files_to_test items = [ item.resolve() - for directory in self.test_directories + for directory in cls.test_directories for item in directory.glob("*.py") if not item.name.startswith("bad") ] @@ -304,10 +306,15 @@ class DirectoryTestCase(ASTTestCase): # Test limited subset of files unless the 'cpu' resource is specified. if not test.support.is_resource_enabled("cpu"): items = random.sample(items, 10) + + # bpo-31174: Store the names sample to always test the same files. + # It prevents false alarms when hunting reference leaks. + cls._files_to_test = items + return items def test_files(self): - for item in self.files_to_test: + for item in self.files_to_test(): if test.support.verbose: print(f"Testing {item.absolute()}") |