-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
43 lines (34 loc) · 1.26 KB
/
main.py
File metadata and controls
43 lines (34 loc) · 1.26 KB
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
import pytest
import argparse
from conf import readYaml, selectProfileEndpoint
def readArgs():
parser = argparse.ArgumentParser(description="Run Selenium tests with following options:")
group = parser.add_mutually_exclusive_group()
group.add_argument("--local", action="store_true", help="Run tests on the local environment")
group.add_argument("--production", action="store_true", help="Run tests on the production environment")
group.add_argument("--stage", action="store_true", help="Run tests on the stage environment")
parser.add_argument("--filename", type=str, help="Run test on a specific file")
args = parser.parse_args()
if sum([args.local, args.production, args.stage]) <= 1:
pass
else:
parser.error("Exactly one of --local, --production, or --stage must be specified")
return args
def selectProfile(args):
if args.production:
return "production"
elif args.stage:
return "stage"
else:
return "local"
def init():
args = readArgs()
profile = selectProfile(args)
readYaml()
selectProfileEndpoint(profile)
if args.filename:
pytest.main(["tests/", "-s", "-k", args.filename])
else:
pytest.main(["tests/"])
if __name__ == "__main__":
init()