1"""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 16from importlib import util 17 18 19class TestFrozen(unittest.TestCase): 20 def test_frozen(self): 21 name = '__hello__' 22 if name in sys.modules: 23 del sys.modules[name] 24 with captured_stdout() as out: 25 import __hello__ 26 self.assertEqual(out.getvalue(), 'Hello world!\n') 27 28 29if __name__ == '__main__': 30 unittest.main() 31