blob: 142f17d518e783e74742ea63bc62828c4cb61fa0 [file] [log] [blame]
Neil Schemenauer1eaa1162017-12-02 13:54:00 -08001"""Basic test of the frozen module (source is in Python/frozen.c)."""
2
3# The Python/frozen.c source code contains a marshalled Python module
4# and therefore depends on the marshal format as well as the bytecode
5# format. If those formats have been changed then frozen.c needs to be
6# updated.
7#
8# The test_importlib also tests this module but because those tests
9# are much more complicated, it might be unclear why they are failing.
10# Invalid marshalled data in frozen.c could case the interpreter to
11# crash when __hello__ is imported.
12
13import sys
14import unittest
15from test.support import captured_stdout
Neil Schemenauer1eaa1162017-12-02 13:54:00 -080016
17
18class TestFrozen(unittest.TestCase):
19 def test_frozen(self):
20 name = '__hello__'
21 if name in sys.modules:
22 del sys.modules[name]
23 with captured_stdout() as out:
24 import __hello__
25 self.assertEqual(out.getvalue(), 'Hello world!\n')
26
27
28if __name__ == '__main__':
29 unittest.main()