cpython/Lib/test/test_tools/__init__.py
Zachary Ware f012ba42fe Issue #22002: Make full use of test discovery in test sub-packages.
Adds `load_package_tests` function to test.support, uses it in test_asyncio,
test_email, test_json, test_tools, test_importlib and all test_importlib
sub-packages to implement test discovery.
2014-07-23 12:00:29 -05:00

25 lines
853 B
Python

"""Support functions for testing scripts in the Tools directory."""
import os
import unittest
import importlib
from test import support
from fnmatch import fnmatch
basepath = os.path.dirname( # <src/install dir>
os.path.dirname( # Lib
os.path.dirname( # test
os.path.dirname(__file__)))) # test_tools
toolsdir = os.path.join(basepath, 'Tools')
scriptsdir = os.path.join(toolsdir, 'scripts')
def skip_if_missing():
if not os.path.isdir(scriptsdir):
raise unittest.SkipTest('scripts directory could not be found')
def import_tool(toolname):
with support.DirsOnSysPath(scriptsdir):
return importlib.import_module(toolname)
def load_tests(*args):
return support.load_package_tests(os.path.dirname(__file__), *args)