blob: fc6fdf83d7d7a8f987a91b2af50721786882946c [file] [log] [blame]
Jeremy Hylton4336eda2004-08-07 19:25:33 +00001import compiler
2import os
3import test.test_support
4import unittest
5
6class CompilerTest(unittest.TestCase):
7
8 def testCompileLibrary(self):
9 # A simple but large test. Compile all the code in the
10 # standard library and its test suite. This doesn't verify
11 # that any of the code is correct, merely the compiler is able
12 # to generate some kind of code for it.
13
14 libdir = os.path.dirname(unittest.__file__)
15 testdir = os.path.dirname(test.test_support.__file__)
16
17 for dir in [libdir, testdir]:
18 for path in os.listdir(dir):
19 if not path.endswith(".py"):
20 continue
21 f = open(os.path.join(dir, path), "r")
22 buf = f.read()
23 f.close()
24 compiler.compile(buf, path, "exec")
25
26def test_main():
27 test.test_support.requires("compiler")
28 test.test_support.run_unittest(CompilerTest)
29
30if __name__ == "__main__":
31 test_main()