@@ -19,51 +19,36 @@ def testCompileLibrary(self):
1919 libdir = os .path .dirname (unittest .__file__ )
2020 testdir = os .path .dirname (test .test_support .__file__ )
2121
22- ## for dir in [libdir, testdir]:
23- ## for basename in os.listdir(dir):
24- ## # Print still working message since this test can be really slow
25- ## if next_time <= time.time():
26- ## next_time = time.time() + _PRINT_WORKING_MSG_INTERVAL
27- ## print >>sys.__stdout__, \
28- ## ' testCompileLibrary still working, be patient...'
29- ## sys.__stdout__.flush()
30- ##
31- ## if not basename.endswith(".py"):
32- ## continue
33- ## if not TEST_ALL and random() < 0.98:
34- ## continue
35- ## path = os.path.join(dir, basename)
36- ## if test.test_support.verbose:
37- ## print "compiling", path
38- ## f = open(path, "U")
39- ## buf = f.read()
40- ## f.close()
41- ## if "badsyntax" in basename or "bad_coding" in basename:
42- ## self.assertRaises(SyntaxError, compiler.compile,
43- ## buf, basename, "exec")
44- ## else:
45- ## try:
46- ## compiler.compile(buf, basename, "exec")
47- ## except Exception, e:
48- ## args = list(e.args)
49- ## args[0] += "[in file %s]" % basename
50- ## e.args = tuple(args)
51- ## raise
52-
53- path = "/home/jiwon/p3yk/Lib/test/test_keywordonlyarg.py"
54- if test .test_support .verbose :
55- print "compiling" , path
56- f = open (path , "U" )
57- buf = f .read ()
58- f .close ()
59- #try:
60- compiler .compile (buf , "test_keywordonlyarg.py" , "exec" )
61- #except Exception, e:
62- # args = list(e.args)
63- # args[0] += "[in file %s]" % path
64- # e.args = tuple(args)
65- # raise
66-
22+ for dir in [libdir , testdir ]:
23+ for basename in os .listdir (dir ):
24+ # Print still working message since this test can be really slow
25+ if next_time <= time .time ():
26+ next_time = time .time () + _PRINT_WORKING_MSG_INTERVAL
27+ print >> sys .__stdout__ , \
28+ ' testCompileLibrary still working, be patient...'
29+ sys .__stdout__ .flush ()
30+
31+ if not basename .endswith (".py" ):
32+ continue
33+ if not TEST_ALL and random () < 0.98 :
34+ continue
35+ path = os .path .join (dir , basename )
36+ if test .test_support .verbose :
37+ print "compiling" , path
38+ f = open (path , "U" )
39+ buf = f .read ()
40+ f .close ()
41+ if "badsyntax" in basename or "bad_coding" in basename :
42+ self .assertRaises (SyntaxError , compiler .compile ,
43+ buf , basename , "exec" )
44+ else :
45+ try :
46+ compiler .compile (buf , basename , "exec" )
47+ except Exception , e :
48+ args = list (e .args )
49+ args [0 ] += "[in file %s]" % basename
50+ e .args = tuple (args )
51+ raise
6752
6853 def testNewClassSyntax (self ):
6954 compiler .compile ("class foo():pass\n \n " ,"<string>" ,"exec" )
0 commit comments