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