forked from jolly-good-toolbelt/sphinx_gherkindoc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_tests.py
executable file
·58 lines (46 loc) · 1.5 KB
/
run_tests.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python3
"""
Run all available tests.
Runs the following commands:
{}
"""
import argparse
from env_setup import execute_command_list
__commands_to_run = [
"poetry run pytest -vv --cov sphinx_gherkindoc --cov-report term-missing"
]
__doc__ = __doc__.format("\n ".join(__commands_to_run))
def run_tests(do_setup=False, self_check=False, verbose=True):
"""Run code checks."""
if self_check:
check_command = "python self_check.py" + ("" if verbose else " -q")
__commands_to_run.insert(0, check_command)
if do_setup:
setup_command = "python env_setup.py" + (" -v" if verbose else "")
__commands_to_run.insert(0, setup_command)
execute_command_list(__commands_to_run, verbose=verbose)
def main():
"""Self check with cli args."""
parser = argparse.ArgumentParser(
formatter_class=argparse.RawDescriptionHelpFormatter, description=__doc__
)
parser.add_argument(
"--setup",
action="store_true",
help='run "./env_setup.py" before running self checks',
)
parser.add_argument(
"--check",
action="store_true",
help='run "./self_check.py" before running self checks',
)
parser.add_argument(
"-q",
"--quiet",
action="store_true",
help="do not show each command before it is executed",
)
args = parser.parse_args()
run_tests(do_setup=args.setup, self_check=args.check, verbose=not args.quiet)
if __name__ == "__main__":
main()