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

Skip to content

Commit be4fb69

Browse files
committed
Issue #14742: test_unparse now only checks a limited number of files unless the 'cpu' resource is specified.
1 parent dc00f1e commit be4fb69

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

Lib/test/test_tools.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ def test_gprof(self):
127127
# Run the tests in Tools/parser/test_unparse.py
128128
with support.DirsOnSysPath(os.path.join(basepath, 'parser')):
129129
from test_unparse import UnparseTestCase
130+
from test_unparse import DirectoryTestCase
130131

131132

132133
def test_main():

Tools/parser/test_unparse.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
import test.support
33
import io
44
import os
5+
import random
56
import tokenize
6-
import ast
77
import unparse
8+
import ast
89

910
def read_pyfile(filename):
1011
"""Read and return the contents of a Python source file (as a
@@ -257,6 +258,10 @@ def test_files(self):
257258
if n.endswith('.py') and not n.startswith('bad'):
258259
names.append(os.path.join(test_dir, n))
259260

261+
# Test limited subset of files unless the 'cpu' resource is specified.
262+
if not test.support.is_resource_enabled("cpu"):
263+
names = random.sample(names, 10)
264+
260265
for filename in names:
261266
if test.support.verbose:
262267
print('Testing %s' % filename)

0 commit comments

Comments
 (0)