(root)/
Python-3.12.0/
Lib/
test/
test_tools/
test_freeze.py
       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  class ESC[4;38;5;81mTestFreeze(ESC[4;38;5;149munittestESC[4;38;5;149m.ESC[4;38;5;149mTestCase):
      19  
      20      @support.requires_resource('cpu') # Building Python is slow
      21      def test_freeze_simple_script(self):
      22          script = textwrap.dedent("""
      23              import sys
      24              print('running...')
      25              sys.exit(0)
      26              """)
      27          with os_helper.temp_dir() as outdir:
      28              outdir, scriptfile, python = helper.prepare(script, outdir)
      29              executable = helper.freeze(python, scriptfile, outdir)
      30              text = helper.run(executable)
      31          self.assertEqual(text, 'running...')