1
1
#!/usr/bin/env python
2
+
2
3
import os
4
+ from shlex import split
5
+
3
6
try :
4
7
from shlex import quote
5
8
except ImportError :
@@ -16,8 +19,8 @@ def prettify_path(path):
16
19
17
20
if __name__ == "__main__" :
18
21
environment = os .getenv ('ENVIRONMENT' )
19
- markers = quote ( os .getenv ('MARKERS' ) )
20
- keywords = quote ( os .getenv ('KEYWORDS' ) )
22
+ markers = os .getenv ('MARKERS' )
23
+ keywords = os .getenv ('KEYWORDS' )
21
24
os_version = os .getenv ('OS' )
22
25
browser = os .getenv ('BROWSER' )
23
26
parallel_sessions = os .getenv ('PARALLEL_SESSIONS' )
@@ -41,29 +44,46 @@ def prettify_path(path):
41
44
assert os .path .isfile (credentials_file )
42
45
43
46
pytest_cmd = [
44
- 'tox' ,
45
- '-epy36' ,
46
- '--' ,
47
- '-vvv' ,
48
- '--variables=capabilities/project.json' ,
49
- '--variables={0}' .format (os_file ),
50
- '--variables={0}' .format (browser_file ),
51
- '--variables={0}' .format (resolution_file ),
52
- '--splinter-webdriver=remote' ,
53
- '--splinter-remote-url={0}' .format (
47
+ "tox" ,
48
+ "-epy36" ,
49
+ "--" ,
50
+ "-vvv" ,
51
+ "--variables" ,
52
+ "capabilities/project.json" ,
53
+ "--variables" ,
54
+ "{0}" .format (os_file ),
55
+ "--variables" ,
56
+ "{0}" .format (browser_file ),
57
+ "--variables" ,
58
+ "{0}" .format (resolution_file ),
59
+ "--splinter-webdriver" ,
60
+ "remote" ,
61
+ "--splinter-remote-url" ,
62
+ "{0}" .format (
54
63
selenium_grid_url ),
55
- '--variables={0}' .format (credentials_file ),
56
- '--junitxml={0}' .format (build_id ),
64
+ "--variables" ,
65
+ "{0}" .format (credentials_file ),
66
+ "--junitxml" ,
67
+ "{0}" .format (build_id ),
57
68
]
58
69
59
70
if markers :
60
- pytest_cmd .append ('-m={0}' .format (markers ))
71
+ pytest_cmd .extend ([
72
+ "-m" ,
73
+ quote (markers ),
74
+ ])
61
75
62
76
if keywords :
63
- pytest_cmd .append ('-k={0}' .format (keywords ))
77
+ pytest_cmd .extend ([
78
+ "-k" ,
79
+ quote (keywords )
80
+ ])
64
81
65
82
if os .getenv ('DEBUG' ) == 'true' :
66
- pytest_cmd .append ('--variables=capabilities/debug.json' )
83
+ pytest_cmd .extend ([
84
+ "--variables" ,
85
+ "capabilities/debug.json"
86
+ ])
67
87
68
88
if os .getenv ('TESTRAIL_ENABLE' ) == 'true' :
69
89
if 'pcmw' in environment :
@@ -79,16 +99,21 @@ def prettify_path(path):
79
99
prettify_path (browser ), markers , keywords ))
80
100
81
101
pytest_cmd .extend ([
82
- '--testrail={0}' .format (testrail_file ),
83
- '--tr_name={0}"' .format (tr_name ),
102
+ "--testrail" ,
103
+ testrail_file ,
104
+ "--tr_name" ,
105
+ tr_name ,
84
106
])
85
107
86
108
if os .getenv ('BLOCK_FIRST_FAILURE' ) == 'true' :
87
109
pytest_cmd .append ('-x' )
88
110
89
111
if parallel_sessions :
90
112
assert isinstance (parallel_sessions , int )
91
- pytest_cmd .append ('-n {0}' .format (parallel_sessions ))
113
+ pytest_cmd .extend ([
114
+ "-n" ,
115
+ parallel_sessions ,
116
+ ])
92
117
93
118
print (str (pytest_cmd ))
94
- run (pytest_cmd )
119
+ run (split ( " " . join ( pytest_cmd )) )
0 commit comments