forked from SALib/SALib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_cli.py
37 lines (29 loc) · 1.04 KB
/
test_cli.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import subprocess
import importlib
from SALib.util import avail_approaches
def test_cli_usage():
cmd = ["salib"]
try:
out = subprocess.check_output(
cmd, stderr=subprocess.STDOUT, shell=True, universal_newlines=True
)
except subprocess.CalledProcessError as e:
raise RuntimeError(f"Call failed:\n{e}")
else:
# if no error raised, check the returned string
assert (
len(out) > 0 and "usage" in out.lower()
), "Incorrect message returned from utility"
def test_cli_avail_methods():
method_types = ["sample", "analyze"]
for method in method_types:
module = importlib.import_module(f"SALib.{method}")
actions = avail_approaches(module)
for act in actions:
approach = importlib.import_module(f"SALib.{method}.{act}")
# Just try to access the functions - raises error on failure
approach.cli_parse
approach.cli_action
if __name__ == "__main__":
test_cli_usage()
test_cli_avail_methods()