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