mirror of
https://github.com/python/cpython.git
synced 2025-07-15 23:35:23 +00:00
Issue #14742: test_unparse now only checks a limited number of files unless the 'cpu' resource is specified.
This commit is contained in:
parent
dc00f1eba0
commit
be4fb69201
2 changed files with 7 additions and 1 deletions
|
@ -127,6 +127,7 @@ class Gprof2htmlTests(unittest.TestCase):
|
||||||
# Run the tests in Tools/parser/test_unparse.py
|
# Run the tests in Tools/parser/test_unparse.py
|
||||||
with support.DirsOnSysPath(os.path.join(basepath, 'parser')):
|
with support.DirsOnSysPath(os.path.join(basepath, 'parser')):
|
||||||
from test_unparse import UnparseTestCase
|
from test_unparse import UnparseTestCase
|
||||||
|
from test_unparse import DirectoryTestCase
|
||||||
|
|
||||||
|
|
||||||
def test_main():
|
def test_main():
|
||||||
|
|
|
@ -2,9 +2,10 @@ import unittest
|
||||||
import test.support
|
import test.support
|
||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
|
import random
|
||||||
import tokenize
|
import tokenize
|
||||||
import ast
|
|
||||||
import unparse
|
import unparse
|
||||||
|
import ast
|
||||||
|
|
||||||
def read_pyfile(filename):
|
def read_pyfile(filename):
|
||||||
"""Read and return the contents of a Python source file (as a
|
"""Read and return the contents of a Python source file (as a
|
||||||
|
@ -257,6 +258,10 @@ class DirectoryTestCase(ASTTestCase):
|
||||||
if n.endswith('.py') and not n.startswith('bad'):
|
if n.endswith('.py') and not n.startswith('bad'):
|
||||||
names.append(os.path.join(test_dir, n))
|
names.append(os.path.join(test_dir, n))
|
||||||
|
|
||||||
|
# Test limited subset of files unless the 'cpu' resource is specified.
|
||||||
|
if not test.support.is_resource_enabled("cpu"):
|
||||||
|
names = random.sample(names, 10)
|
||||||
|
|
||||||
for filename in names:
|
for filename in names:
|
||||||
if test.support.verbose:
|
if test.support.verbose:
|
||||||
print('Testing %s' % filename)
|
print('Testing %s' % filename)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue