[Python-checkins] bpo-31174: Improve the code of test_tools.test_unparse. (GH-4146) (#4148)
Serhiy Storchaka
webhook-mailer at python.org
Fri Oct 27 09:17:39 EDT 2017
https://github.com/python/cpython/commit/bb78898224c99cbf9c6beed8706869f9b66967c2
commit: bb78898224c99cbf9c6beed8706869f9b66967c2
branch: 3.6
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Serhiy Storchaka <storchaka at gmail.com>
date: 2017-10-27T16:17:36+03:00
summary:
bpo-31174: Improve the code of test_tools.test_unparse. (GH-4146) (#4148)
(cherry picked from commit 7351f9e5a91c403d15c6d556f9989b443f1296f9)
files:
M Lib/test/test_tools/test_unparse.py
diff --git a/Lib/test/test_tools/test_unparse.py b/Lib/test/test_tools/test_unparse.py
index bab49df3312..f3386f5e31a 100644
--- a/Lib/test/test_tools/test_unparse.py
+++ b/Lib/test/test_tools/test_unparse.py
@@ -268,12 +268,13 @@ class DirectoryTestCase(ASTTestCase):
# test directories, relative to the root of the distribution
test_directories = 'Lib', os.path.join('Lib', 'test')
- def get_names(self):
- if DirectoryTestCase.NAMES is not None:
- return DirectoryTestCase.NAMES
+ @classmethod
+ def get_names(cls):
+ if cls.NAMES is not None:
+ return cls.NAMES
names = []
- for d in self.test_directories:
+ for d in cls.test_directories:
test_dir = os.path.join(basepath, d)
for n in os.listdir(test_dir):
if n.endswith('.py') and not n.startswith('bad'):
@@ -282,10 +283,9 @@ def get_names(self):
# 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
-
+ # bpo-31174: Store the names sample to always test the same files.
+ # It prevents false alarms when hunting reference leaks.
+ cls.NAMES = names
return names
def test_files(self):
More information about the Python-checkins
mailing list