move sections
[python/dscho.git] / Lib / test / test_frozen.py
blob7fb53a4ba6ed789c2ea067bb5ab1e2a8ab52e177
1 # Test the frozen module defined in frozen.c.
3 from test.test_support import captured_stdout, run_unittest
4 import unittest
5 import sys
7 class FrozenTests(unittest.TestCase):
8 def test_frozen(self):
10 with captured_stdout() as stdout:
11 try:
12 import __hello__
13 except ImportError, x:
14 self.fail("import __hello__ failed:" + str(x))
16 try:
17 import __phello__
18 except ImportError, x:
19 self.fail("import __phello__ failed:" + str(x))
21 try:
22 import __phello__.spam
23 except ImportError, x:
24 self.fail("import __phello__.spam failed:" + str(x))
26 try:
27 import __phello__.foo
28 except ImportError:
29 pass
30 else:
31 self.fail("import __phello__.foo should have failed")
33 self.assertEquals(stdout.getvalue(),
34 'Hello world...\nHello world...\nHello world...\n')
36 del sys.modules['__hello__']
37 del sys.modules['__phello__']
38 del sys.modules['__phello__.spam']
41 def test_main():
42 run_unittest(FrozenTests)
46 if __name__ == '__main__':
47 test_main()