diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2017-10-24 10:33:36 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-24 10:33:36 (GMT) |
commit | 8e482bea21cb942804234e36d3c6c896aabd32da (patch) | |
tree | c19bfac3bb7a15c7500789251d9b764b88c4b598 /Lib | |
parent | 809d173c2005ed76f5b6cb178a0cce3f88121883 (diff) | |
download | cpython-8e482bea21cb942804234e36d3c6c896aabd32da.zip cpython-8e482bea21cb942804234e36d3c6c896aabd32da.tar.gz cpython-8e482bea21cb942804234e36d3c6c896aabd32da.tar.bz2 |
bpo-31174: Fix test_tools.test_unparse (#4102)
test_unparse.DirectoryTestCase now stores the names sample to always
test the same files. It prevents false alarms when hunting reference
leaks.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_tools/test_unparse.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/Lib/test/test_tools/test_unparse.py b/Lib/test/test_tools/test_unparse.py index 65dee1b..bab49df 100644 --- a/Lib/test/test_tools/test_unparse.py +++ b/Lib/test/test_tools/test_unparse.py @@ -263,12 +263,14 @@ class UnparseTestCase(ASTTestCase): class DirectoryTestCase(ASTTestCase): """Test roundtrip behaviour on all files in Lib and Lib/test.""" + NAMES = None # test directories, relative to the root of the distribution test_directories = 'Lib', os.path.join('Lib', 'test') - def test_files(self): - # get names of files to test + def get_names(self): + if DirectoryTestCase.NAMES is not None: + return DirectoryTestCase.NAMES names = [] for d in self.test_directories: @@ -280,6 +282,15 @@ class DirectoryTestCase(ASTTestCase): # Test limited subset of files unless the 'cpu' resource is specified. if not test.support.is_resource_enabled("cpu"): names = random.sample(names, 10) + # bpo-31174: Store the names sample to always test the same files. + # It prevents false alarms when hunting reference leaks. + DirectoryTestCase.NAMES = names + + return names + + def test_files(self): + # get names of files to test + names = self.get_names() for filename in names: if test.support.verbose: |