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@unittest.skipIf(sys.platform == 'darwin' and sys._framework, 18 'not supported for frameworks builds on macOS') 19@support.skip_if_buildbot('not all buildbots have enough space') 20# gh-103053: Skip test if Python is built with Profile Guided Optimization 21# (PGO), since the test is just too slow in this case. 22@unittest.skipIf(support.check_cflags_pgo(), 23 'test is too slow with PGO') 24class TestFreeze(unittest.TestCase): 25 26 @support.requires_resource('cpu') # Building Python is slow 27 def test_freeze_simple_script(self): 28 script = textwrap.dedent(""" 29 import sys 30 print('running...') 31 sys.exit(0) 32 """) 33 with os_helper.temp_dir() as outdir: 34 outdir, scriptfile, python = helper.prepare(script, outdir) 35 executable = helper.freeze(python, scriptfile, outdir) 36 text = helper.run(executable) 37 self.assertEqual(text, 'running...') 38