From 25046448f5224b9359ad677b5e06f80936513bf0 Mon Sep 17 00:00:00 2001 From: Kaxil Naik Date: Wed, 8 May 2024 07:53:26 +0100 Subject: [PATCH] Fix side effects in AWS Batch Executor test (#39474) This wasted a lot of my hours in debugging failures for https://github.com/apache/airflow/pull/39450 This was modifying a global env vars and causing side effects in other tests --- .../amazon/aws/executors/batch/test_batch_executor.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/providers/amazon/aws/executors/batch/test_batch_executor.py b/tests/providers/amazon/aws/executors/batch/test_batch_executor.py index 8a5773bdca90a..5650f04b60bc6 100644 --- a/tests/providers/amazon/aws/executors/batch/test_batch_executor.py +++ b/tests/providers/amazon/aws/executors/batch/test_batch_executor.py @@ -537,11 +537,9 @@ def test_start_health_check_config(self, set_env_vars): batch_mock.describe_jobs.side_effect = {} executor.batch = batch_mock - os.environ[f"AIRFLOW__{CONFIG_GROUP_NAME}__{AllBatchConfigKeys.CHECK_HEALTH_ON_STARTUP}".upper()] = ( - "False" - ) - - executor.start() + env_var_key = f"AIRFLOW__{CONFIG_GROUP_NAME}__{AllBatchConfigKeys.CHECK_HEALTH_ON_STARTUP}".upper() + with mock.patch.dict(os.environ, {env_var_key: "False"}): + executor.start() batch_mock.describe_jobs.assert_not_called()