Home | History | Annotate | Download | only in test_tools
      1 """Support functions for testing scripts in the Tools directory."""
      2 import os
      3 import unittest
      4 import importlib
      5 from test import support
      6 
      7 basepath = os.path.dirname(                 # <src/install dir>
      8                 os.path.dirname(                # Lib
      9                     os.path.dirname(                # test
     10                         os.path.dirname(__file__))))    # test_tools
     11 
     12 toolsdir = os.path.join(basepath, 'Tools')
     13 scriptsdir = os.path.join(toolsdir, 'scripts')
     14 
     15 def skip_if_missing():
     16     if not os.path.isdir(scriptsdir):
     17         raise unittest.SkipTest('scripts directory could not be found')
     18 
     19 def import_tool(toolname):
     20     with support.DirsOnSysPath(scriptsdir):
     21         return importlib.import_module(toolname)
     22 
     23 def load_tests(*args):
     24     return support.load_package_tests(os.path.dirname(__file__), *args)
     25