Kaydet (Commit) 8e482bea authored tarafından Victor Stinner's avatar Victor Stinner Kaydeden (comit) GitHub

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.
üst 809d173c
...@@ -263,12 +263,14 @@ class UnparseTestCase(ASTTestCase): ...@@ -263,12 +263,14 @@ class UnparseTestCase(ASTTestCase):
class DirectoryTestCase(ASTTestCase): class DirectoryTestCase(ASTTestCase):
"""Test roundtrip behaviour on all files in Lib and Lib/test.""" """Test roundtrip behaviour on all files in Lib and Lib/test."""
NAMES = None
# test directories, relative to the root of the distribution # test directories, relative to the root of the distribution
test_directories = 'Lib', os.path.join('Lib', 'test') test_directories = 'Lib', os.path.join('Lib', 'test')
def test_files(self): def get_names(self):
# get names of files to test if DirectoryTestCase.NAMES is not None:
return DirectoryTestCase.NAMES
names = [] names = []
for d in self.test_directories: for d in self.test_directories:
...@@ -280,6 +282,15 @@ class DirectoryTestCase(ASTTestCase): ...@@ -280,6 +282,15 @@ class DirectoryTestCase(ASTTestCase):
# Test limited subset of files unless the 'cpu' resource is specified. # Test limited subset of files unless the 'cpu' resource is specified.
if not test.support.is_resource_enabled("cpu"): if not test.support.is_resource_enabled("cpu"):
names = random.sample(names, 10) 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: for filename in names:
if test.support.verbose: if test.support.verbose:
......
Fix test_tools.test_unparse: DirectoryTestCase now stores the names sample
to always test the same files. It prevents false alarms when hunting
reference leaks.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment