Skip to content

Commit 7351f9e

Browse files
bpo-31174: Improve the code of test_tools.test_unparse. (python#4146)
1 parent 03eb11f commit 7351f9e

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Lib/test/test_tools/test_unparse.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,13 @@ class DirectoryTestCase(ASTTestCase):
268268
# test directories, relative to the root of the distribution
269269
test_directories = 'Lib', os.path.join('Lib', 'test')
270270

271-
def get_names(self):
272-
if DirectoryTestCase.NAMES is not None:
273-
return DirectoryTestCase.NAMES
271+
@classmethod
272+
def get_names(cls):
273+
if cls.NAMES is not None:
274+
return cls.NAMES
274275

275276
names = []
276-
for d in self.test_directories:
277+
for d in cls.test_directories:
277278
test_dir = os.path.join(basepath, d)
278279
for n in os.listdir(test_dir):
279280
if n.endswith('.py') and not n.startswith('bad'):
@@ -282,10 +283,9 @@ def get_names(self):
282283
# Test limited subset of files unless the 'cpu' resource is specified.
283284
if not test.support.is_resource_enabled("cpu"):
284285
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-
286+
# bpo-31174: Store the names sample to always test the same files.
287+
# It prevents false alarms when hunting reference leaks.
288+
cls.NAMES = names
289289
return names
290290

291291
def test_files(self):

0 commit comments

Comments
 (0)