mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
Jiwon Seo's PEP 3102 implementation.
See SF#1549670. The compiler package has not yet been updated.
This commit is contained in:
parent
fc2a0a8e3c
commit
4f72a78684
31 changed files with 739 additions and 227 deletions
|
@ -19,36 +19,51 @@ class CompilerTest(unittest.TestCase):
|
|||
libdir = os.path.dirname(unittest.__file__)
|
||||
testdir = os.path.dirname(test.test_support.__file__)
|
||||
|
||||
for dir in [libdir, testdir]:
|
||||
for basename in os.listdir(dir):
|
||||
# Print still working message since this test can be really slow
|
||||
if next_time <= time.time():
|
||||
next_time = time.time() + _PRINT_WORKING_MSG_INTERVAL
|
||||
print >>sys.__stdout__, \
|
||||
' testCompileLibrary still working, be patient...'
|
||||
sys.__stdout__.flush()
|
||||
## for dir in [libdir, testdir]:
|
||||
## for basename in os.listdir(dir):
|
||||
## # Print still working message since this test can be really slow
|
||||
## if next_time <= time.time():
|
||||
## next_time = time.time() + _PRINT_WORKING_MSG_INTERVAL
|
||||
## print >>sys.__stdout__, \
|
||||
## ' testCompileLibrary still working, be patient...'
|
||||
## sys.__stdout__.flush()
|
||||
##
|
||||
## if not basename.endswith(".py"):
|
||||
## continue
|
||||
## if not TEST_ALL and random() < 0.98:
|
||||
## continue
|
||||
## path = os.path.join(dir, basename)
|
||||
## if test.test_support.verbose:
|
||||
## print "compiling", path
|
||||
## f = open(path, "U")
|
||||
## buf = f.read()
|
||||
## f.close()
|
||||
## if "badsyntax" in basename or "bad_coding" in basename:
|
||||
## self.assertRaises(SyntaxError, compiler.compile,
|
||||
## buf, basename, "exec")
|
||||
## else:
|
||||
## try:
|
||||
## compiler.compile(buf, basename, "exec")
|
||||
## except Exception, e:
|
||||
## args = list(e.args)
|
||||
## args[0] += "[in file %s]" % basename
|
||||
## e.args = tuple(args)
|
||||
## raise
|
||||
|
||||
path = "/home/jiwon/p3yk/Lib/test/test_keywordonlyarg.py"
|
||||
if test.test_support.verbose:
|
||||
print "compiling", path
|
||||
f = open(path, "U")
|
||||
buf = f.read()
|
||||
f.close()
|
||||
#try:
|
||||
compiler.compile(buf, "test_keywordonlyarg.py", "exec")
|
||||
#except Exception, e:
|
||||
# args = list(e.args)
|
||||
# args[0] += "[in file %s]" % path
|
||||
# e.args = tuple(args)
|
||||
# raise
|
||||
|
||||
if not basename.endswith(".py"):
|
||||
continue
|
||||
if not TEST_ALL and random() < 0.98:
|
||||
continue
|
||||
path = os.path.join(dir, basename)
|
||||
if test.test_support.verbose:
|
||||
print "compiling", path
|
||||
f = open(path, "U")
|
||||
buf = f.read()
|
||||
f.close()
|
||||
if "badsyntax" in basename or "bad_coding" in basename:
|
||||
self.assertRaises(SyntaxError, compiler.compile,
|
||||
buf, basename, "exec")
|
||||
else:
|
||||
try:
|
||||
compiler.compile(buf, basename, "exec")
|
||||
except Exception, e:
|
||||
args = list(e.args)
|
||||
args[0] += "[in file %s]" % basename
|
||||
e.args = tuple(args)
|
||||
raise
|
||||
|
||||
def testNewClassSyntax(self):
|
||||
compiler.compile("class foo():pass\n\n","<string>","exec")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue