blob: 621720ca788fe707fe787d86e23cc03ab0caf8bf [file] [log] [blame]
Guido van Rossum4114a4a2001-10-18 18:49:37 +00001# Test the frozen module defined in frozen.c.
Georg Brandl692bbc42007-08-24 18:22:54 +00002from __future__ import with_statement
Guido van Rossum4114a4a2001-10-18 18:49:37 +00003
Georg Brandl692bbc42007-08-24 18:22:54 +00004from test.test_support import captured_stdout, run_unittest
5import unittest
Guido van Rossum4114a4a2001-10-18 18:49:37 +00006import sys, os
7
Georg Brandl692bbc42007-08-24 18:22:54 +00008class FrozenTests(unittest.TestCase):
9 def test_frozen(self):
Guido van Rossum4114a4a2001-10-18 18:49:37 +000010
Georg Brandl692bbc42007-08-24 18:22:54 +000011 with captured_stdout() as stdout:
12 try:
13 import __hello__
14 except ImportError, x:
15 self.fail("import __hello__ failed:" + str(x))
Guido van Rossum4114a4a2001-10-18 18:49:37 +000016
Georg Brandl692bbc42007-08-24 18:22:54 +000017 try:
18 import __phello__
19 except ImportError, x:
20 self.fail("import __phello__ failed:" + str(x))
Guido van Rossum4114a4a2001-10-18 18:49:37 +000021
Georg Brandl692bbc42007-08-24 18:22:54 +000022 try:
23 import __phello__.spam
24 except ImportError, x:
25 self.fail("import __phello__.spam failed:" + str(x))
26
27 if sys.platform != "mac": # On the Mac this import does succeed.
28 try:
29 import __phello__.foo
30 except ImportError:
31 pass
32 else:
33 self.fail("import __phello__.foo should have failed")
34
35 self.assertEquals(stdout.getvalue(),
36 'Hello world...\nHello world...\nHello world...\n')
37
38
39def test_main():
40 run_unittest(FrozenTests)