equal
deleted
inserted
replaced
|
1 # Test the frozen module defined in frozen.c. |
|
2 |
|
3 from test.test_support import captured_stdout, run_unittest |
|
4 import unittest |
|
5 import sys, os |
|
6 |
|
7 class FrozenTests(unittest.TestCase): |
|
8 def test_frozen(self): |
|
9 |
|
10 with captured_stdout() as stdout: |
|
11 try: |
|
12 import __hello__ |
|
13 except ImportError, x: |
|
14 self.fail("import __hello__ failed:" + str(x)) |
|
15 |
|
16 try: |
|
17 import __phello__ |
|
18 except ImportError, x: |
|
19 self.fail("import __phello__ failed:" + str(x)) |
|
20 |
|
21 try: |
|
22 import __phello__.spam |
|
23 except ImportError, x: |
|
24 self.fail("import __phello__.spam failed:" + str(x)) |
|
25 |
|
26 if sys.platform != "mac": # On the Mac this import does succeed. |
|
27 try: |
|
28 import __phello__.foo |
|
29 except ImportError: |
|
30 pass |
|
31 else: |
|
32 self.fail("import __phello__.foo should have failed") |
|
33 |
|
34 self.assertEquals(stdout.getvalue(), |
|
35 'Hello world...\nHello world...\nHello world...\n') |
|
36 |
|
37 del sys.modules['__hello__'] |
|
38 del sys.modules['__phello__'] |
|
39 del sys.modules['__phello__.spam'] |
|
40 |
|
41 |
|
42 def test_main(): |
|
43 run_unittest(FrozenTests) |
|
44 |
|
45 |
|
46 |
|
47 if __name__ == '__main__': |
|
48 test_main() |