Jeremy Hylton | 4336eda | 2004-08-07 19:25:33 +0000 | [diff] [blame] | 1 | import compiler |
| 2 | import os |
| 3 | import test.test_support |
| 4 | import unittest |
| 5 | |
| 6 | class 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 | |
| 26 | def test_main(): |
| 27 | test.test_support.requires("compiler") |
| 28 | test.test_support.run_unittest(CompilerTest) |
| 29 | |
| 30 | if __name__ == "__main__": |
| 31 | test_main() |