summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_tools/__init__.py
diff options
context:
space:
mode:
authorZachary Ware <zachary.ware@gmail.com>2014-07-16 19:26:09 (GMT)
committerZachary Ware <zachary.ware@gmail.com>2014-07-16 19:26:09 (GMT)
commit2b0a6102974bdcacf8b8c4d964d3f7379878100a (patch)
tree2a18ee067b685b0a7af77e1d1b2f52138a996fa4 /Lib/test/test_tools/__init__.py
parent52b2bc03693d663fe1d1bdf974c23800232213dd (diff)
downloadcpython-2b0a6102974bdcacf8b8c4d964d3f7379878100a.zip
cpython-2b0a6102974bdcacf8b8c4d964d3f7379878100a.tar.gz
cpython-2b0a6102974bdcacf8b8c4d964d3f7379878100a.tar.bz2
Issue #21918: Convert test_tools.py to a sub-package of test.
Diffstat (limited to 'Lib/test/test_tools/__init__.py')
-rw-r--r--Lib/test/test_tools/__init__.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/Lib/test/test_tools/__init__.py b/Lib/test/test_tools/__init__.py
new file mode 100644
index 0000000..9b94cb4
--- /dev/null
+++ b/Lib/test/test_tools/__init__.py
@@ -0,0 +1,31 @@
+"""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(loader, standard_tests, pattern):
+ this_dir = os.path.dirname(__file__)
+ if pattern is None:
+ pattern = "test*"
+ with support.DirsOnSysPath():
+ package_tests = loader.discover(start_dir=this_dir, pattern=pattern)
+ standard_tests.addTests(package_tests)
+ return standard_tests