python (3.11.7)
       1  """Sanity-check tests for the "freeze" tool."""
       2  
       3  import sys
       4  import textwrap
       5  import unittest
       6  
       7  from test import support
       8  from test.support import os_helper
       9  from test.test_tools import imports_under_tool, skip_if_missing
      10  
      11  skip_if_missing('freeze')
      12  with 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')
      18  # gh-103053: Skip test if Python is built with Profile Guided Optimization
      19  # (PGO), since the test is just too slow in this case.
      20  @unittest.skipIf(support.check_cflags_pgo(),
      21                   'test is too slow with PGO')
      22  class ESC[4;38;5;81mTestFreeze(ESC[4;38;5;149munittestESC[4;38;5;149m.ESC[4;38;5;149mTestCase):
      23  
      24      @support.requires_resource('cpu') # Building Python is slow
      25      def test_freeze_simple_script(self):
      26          script = textwrap.dedent("""
      27              import sys
      28              print('running...')
      29              sys.exit(0)
      30              """)
      31          with os_helper.temp_dir() as outdir:
      32              outdir, scriptfile, python = helper.prepare(script, outdir)
      33              executable = helper.freeze(python, scriptfile, outdir)
      34              text = helper.run(executable)
      35          self.assertEqual(text, 'running...')