@@ -236,8 +236,8 @@ def session(
236236 rule2 = f"rule2{ Utils .random_alphanumeric_str (10 )} "
237237 key1 = f"key1{ Utils .random_alphanumeric_str (10 )} "
238238 key2 = f"key2{ Utils .random_alphanumeric_str (10 )} "
239- integration1 = f"integration1 { Utils .random_alphanumeric_str (10 )} "
240- integration2 = f"integration2 { Utils .random_alphanumeric_str (10 )} "
239+ integration1 = f"integration1_ { Utils .random_alphanumeric_str (10 )} "
240+ integration2 = f"integration2_ { Utils .random_alphanumeric_str (10 )} "
241241
242242 session = (
243243 Session .builder .configs (db_parameters )
@@ -248,7 +248,7 @@ def session(
248248 session ._cte_optimization_enabled = cte_optimization_enabled
249249 session .ast_enabled = ast_enabled
250250
251- if os . getenv ( "GITHUB_ACTIONS" ) == "true" and not local_testing_mode :
251+ if RUNNING_ON_GH and not local_testing_mode :
252252 set_up_external_access_integration_resources (
253253 session , rule1 , rule2 , key1 , key2 , integration1 , integration2
254254 )
@@ -258,16 +258,18 @@ def session(
258258 session , db_parameters , unparser_jar
259259 )
260260
261- yield session
261+ try :
262+ yield session
262263
263- if validate_ast :
264- close_full_ast_validation_mode (full_ast_validation_listener )
264+ finally :
265+ if validate_ast :
266+ close_full_ast_validation_mode (full_ast_validation_listener )
265267
266- if os . getenv ( "GITHUB_ACTIONS" ) == "true" and not local_testing_mode :
267- clean_up_external_access_integration_resources (
268- session , rule1 , rule2 , key1 , key2 , integration1 , integration2
269- )
270- session .close ()
268+ if RUNNING_ON_GH and not local_testing_mode :
269+ clean_up_external_access_integration_resources (
270+ session , rule1 , rule2 , key1 , key2 , integration1 , integration2
271+ )
272+ session .close ()
271273
272274
273275@pytest .fixture (scope = "function" )
@@ -282,25 +284,27 @@ def profiler_session(
282284 rule2 = f"rule2{ Utils .random_alphanumeric_str (10 )} "
283285 key1 = f"key1{ Utils .random_alphanumeric_str (10 )} "
284286 key2 = f"key2{ Utils .random_alphanumeric_str (10 )} "
285- integration1 = f"integration1 { Utils .random_alphanumeric_str (10 )} "
286- integration2 = f"integration2 { Utils .random_alphanumeric_str (10 )} "
287+ integration1 = f"integration1_ { Utils .random_alphanumeric_str (10 )} "
288+ integration2 = f"integration2_ { Utils .random_alphanumeric_str (10 )} "
287289 session = (
288290 Session .builder .configs (db_parameters )
289291 .config ("local_testing" , local_testing_mode )
290292 .create ()
291293 )
292294 session .sql_simplifier_enabled = sql_simplifier_enabled
293295 session ._cte_optimization_enabled = cte_optimization_enabled
294- if os . getenv ( "GITHUB_ACTIONS" ) == "true" and not local_testing_mode :
296+ if RUNNING_ON_GH and not local_testing_mode :
295297 set_up_external_access_integration_resources (
296298 session , rule1 , rule2 , key1 , key2 , integration1 , integration2
297299 )
298- yield session
299- if os .getenv ("GITHUB_ACTIONS" ) == "true" and not local_testing_mode :
300- clean_up_external_access_integration_resources (
301- session , rule1 , rule2 , key1 , key2 , integration1 , integration2
302- )
303- session .close ()
300+ try :
301+ yield session
302+ finally :
303+ if RUNNING_ON_GH and not local_testing_mode :
304+ clean_up_external_access_integration_resources (
305+ session , rule1 , rule2 , key1 , key2 , integration1 , integration2
306+ )
307+ session .close ()
304308
305309
306310@pytest .fixture (scope = "function" )
0 commit comments