-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtest.py
45 lines (38 loc) · 1.14 KB
/
test.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
import pytest
import argparse
class ArgsParser:
def __init__(self) -> None:
self.parser = argparse.ArgumentParser(
description="Run pytest with specified arguments",
epilog="""
Example Usage:
python test.py -k test_setTheme
python test.py -f tests/ui/test_output_tab.py -k test_initial_state
""",
formatter_class=argparse.RawTextHelpFormatter
)
self._populateArgs()
def _populateArgs(self) -> None:
self.parser.add_argument(
"-k", "--keyword",
action="store",
help="Run tests by keyword."
)
self.parser.add_argument(
"-f", "--file",
action="store",
help="Run tests from the specified file."
)
def parseArgs(self):
return self.parser.parse_args()
if __name__ == "__main__":
parser = ArgsParser()
args = parser.parseArgs()
pytest_args = ["-q"]
if args.file:
pytest_args.extend([args.file])
else:
pytest_args.extend(["tests/"])
if args.keyword:
pytest_args.extend(["-k", args.keyword])
pytest.main(pytest_args)