(root)/
Python-3.12.0/
Lib/
test/
test_tools/
test_sundry.py
       1  """Tests for scripts in the Tools/scripts directory.
       2  
       3  This file contains extremely basic regression tests for the scripts found in
       4  the Tools directory of a Python checkout or tarball which don't have separate
       5  tests of their own.
       6  """
       7  
       8  import os
       9  import unittest
      10  from test.support import import_helper
      11  
      12  from test.test_tools import scriptsdir, import_tool, skip_if_missing
      13  
      14  skip_if_missing()
      15  
      16  class ESC[4;38;5;81mTestSundryScripts(ESC[4;38;5;149munittestESC[4;38;5;149m.ESC[4;38;5;149mTestCase):
      17      # At least make sure the rest don't have syntax errors.  When tests are
      18      # added for a script it should be added to the allowlist below.
      19  
      20      skiplist = ['2to3']
      21  
      22      # import logging registers "atfork" functions which keep indirectly the
      23      # logging module dictionary alive. Mock the function to be able to unload
      24      # cleanly the logging module.
      25      @import_helper.mock_register_at_fork
      26      def test_sundry(self, mock_os):
      27          old_modules = import_helper.modules_setup()
      28          try:
      29              for fn in os.listdir(scriptsdir):
      30                  if not fn.endswith('.py'):
      31                      continue
      32  
      33                  name = fn[:-3]
      34                  if name in self.skiplist:
      35                      continue
      36  
      37                  import_tool(name)
      38          finally:
      39              # Unload all modules loaded in this test
      40              import_helper.modules_cleanup(*old_modules)
      41  
      42  
      43  if __name__ == '__main__':
      44      unittest.main()