1"""Sanity-check tests for the "freeze" tool."""
2
3import sys
4import textwrap
5import unittest
6
7from test import support
8from test.support import os_helper
9from test.test_tools import imports_under_tool, skip_if_missing
10
11skip_if_missing('freeze')
12with imports_under_tool('freeze', 'test'):
13    import freeze as helper
14
15@support.requires_zlib()
16@unittest.skipIf(sys.platform.startswith('win'), 'not supported on Windows')
17@support.skip_if_buildbot('not all buildbots have enough space')
18class TestFreeze(unittest.TestCase):
19
20    def test_freeze_simple_script(self):
21        script = textwrap.dedent("""
22            import sys
23            print('running...')
24            sys.exit(0)
25            """)
26        with os_helper.temp_dir() as outdir:
27            outdir, scriptfile, python = helper.prepare(script, outdir)
28            executable = helper.freeze(python, scriptfile, outdir)
29            text = helper.run(executable)
30        self.assertEqual(text, 'running...')
31