diff -r ee48728e3695 Tools/parser/test_unparse.py --- a/Tools/parser/test_unparse.py Fri Jan 25 15:35:12 2013 +0100 +++ b/Tools/parser/test_unparse.py Mon Jan 28 09:58:17 2013 +0200 @@ -2,7 +2,6 @@ import test.support import io import os -import random import tokenize import unparse import ast @@ -242,25 +241,30 @@ class DirectoryTestCase(ASTTestCase): - """Test roundtrip behaviour on all files in Lib and Lib/test.""" + """Test roundtrip behaviour on all files in Lib and Lib/test. + In case the "cpu" resource is not enabled, behaviour on + only one file - test_gramar.py - is tested.""" # test directories, relative to the root of the distribution test_directories = 'Lib', os.path.join('Lib', 'test') def test_files(self): - # get names of files to test - dist_dir = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir) names = [] - for d in self.test_directories: - test_dir = os.path.join(dist_dir, d) - for n in os.listdir(test_dir): - if n.endswith('.py') and not n.startswith('bad'): - names.append(os.path.join(test_dir, n)) + # Test one file unless the 'cpu' resource is specified. + if test.support.is_resource_enabled("cpu"): + # get names of files to test + dist_dir = os.path.join( + os.path.dirname(__file__), os.pardir, os.pardir) - # 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 d in self.test_directories: + test_dir = os.path.join(dist_dir, d) + for n in os.listdir(test_dir): + if n.endswith('.py') and not n.startswith('bad'): + names.append(os.path.join(test_dir, n)) + else: + names.append( + os.path.join(self.test_directories[1], "test_grammar.py")) for filename in names: if test.support.verbose: