Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8e482be

Browse files
authored
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.
1 parent 809d173 commit 8e482be

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

Lib/test/test_tools/test_unparse.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,14 @@ def test_dict_unpacking_in_dict(self):
263263

264264
class DirectoryTestCase(ASTTestCase):
265265
"""Test roundtrip behaviour on all files in Lib and Lib/test."""
266+
NAMES = None
266267

267268
# test directories, relative to the root of the distribution
268269
test_directories = 'Lib', os.path.join('Lib', 'test')
269270

270-
def test_files(self):
271-
# get names of files to test
271+
def get_names(self):
272+
if DirectoryTestCase.NAMES is not None:
273+
return DirectoryTestCase.NAMES
272274

273275
names = []
274276
for d in self.test_directories:
@@ -280,6 +282,15 @@ def test_files(self):
280282
# Test limited subset of files unless the 'cpu' resource is specified.
281283
if not test.support.is_resource_enabled("cpu"):
282284
names = random.sample(names, 10)
285+
# bpo-31174: Store the names sample to always test the same files.
286+
# It prevents false alarms when hunting reference leaks.
287+
DirectoryTestCase.NAMES = names
288+
289+
return names
290+
291+
def test_files(self):
292+
# get names of files to test
293+
names = self.get_names()
283294

284295
for filename in names:
285296
if test.support.verbose:
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix test_tools.test_unparse: DirectoryTestCase now stores the names sample
2+
to always test the same files. It prevents false alarms when hunting
3+
reference leaks.

0 commit comments

Comments
 (0)