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