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