@@ -93,6 +93,7 @@ def run_tests(reg, site, flg, all_tests):
93
93
flg (list[str]): The list of pytest flags to be used.
94
94
all_tests (list[str]): The list of test file paths to execute.
95
95
"""
96
+ all_tests = remove_skipped_tests (all_tests , site , reg )
96
97
try :
97
98
if len (all_tests ) > 0 :
98
99
logging .info (f"Tests for { reg } region on { site } page." )
@@ -132,6 +133,59 @@ def get_region_tests(test_region: str) -> list[str]:
132
133
)
133
134
134
135
136
+ def remove_skipped_tests (extracted_tests , live_site , reg ):
137
+ """
138
+ Reads the mapping for the given region and site and removes any tests that are marked as skipped.
139
+
140
+ Args:
141
+ extracted_tests (list[str]): The list of test file paths to execute.
142
+ live_site (str): Page being tested.
143
+ reg (str): The test region identifier.
144
+ Returns:
145
+ list[str]: A list of test file paths for the given region.
146
+ """
147
+ mid_path = f"/{ reg } /" if live_site != "demo" else "/"
148
+ live_sites = [
149
+ (f"{ live_site } { mid_path } { live_site } _{ suffix } " , f"_{ suffix } _" )
150
+ for suffix in ("ad" , "cc" )
151
+ ]
152
+ for live_site , suffix in live_sites :
153
+ skipped_tests = get_skipped_tests (live_site )
154
+ if skipped_tests and skipped_tests != "All" :
155
+ skipped_tests = list (
156
+ map (
157
+ lambda test : os .path .join (current_dir , "Unified" , test ),
158
+ skipped_tests ,
159
+ )
160
+ )
161
+
162
+ def should_keep_test (test ):
163
+ return (
164
+ suffix not in test
165
+ if skipped_tests == "All"
166
+ else test not in skipped_tests
167
+ )
168
+
169
+ extracted_tests = list (filter (should_keep_test , extracted_tests ))
170
+ return extracted_tests
171
+
172
+
173
+ def get_skipped_tests (live_site ) -> list [str ] | str :
174
+ """
175
+ Read the mapping for the given region and site and return any tests that are marked as skipped.
176
+
177
+ Arg:
178
+ live_site (str): The site is being tested.
179
+ Returns:
180
+ list[str] | str: A list of tests that should be skipped, or "All" if all tests should be skipped.
181
+ """
182
+ with open (current_dir + "/constants/" + live_site + ".json" , "r" ) as fp :
183
+ live_site_data = load (fp )
184
+ if live_site_data .get ("skip" ):
185
+ return "All"
186
+ return live_site_data .get ("skipped" , [])
187
+
188
+
135
189
def get_flags_and_sanitize (flags_arguments : list [str ]) -> list [str ]:
136
190
"""
137
191
Extract and validate pytest flags from command-line arguments.
@@ -149,7 +203,7 @@ def get_flags_and_sanitize(flags_arguments: list[str]) -> list[str]:
149
203
# add workers and rerun flaky failed tests.
150
204
flg = []
151
205
expanded_args = [
152
- flag .split () if " " in flag else [flag ] for flag in flags_arguments
206
+ flag .split () if "--" not in flag else [flag ] for flag in flags_arguments
153
207
]
154
208
flags_arguments [:] = sum (expanded_args , [])
155
209
for arg in flags_arguments [:]:
0 commit comments