This is an automated email from the ASF dual-hosted git repository.
husseinawala pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 732eba98b2 Replace sequence concatination by unpacking in Airflow
tests (#33935)
732eba98b2 is described below
commit 732eba98b2f485646646574052c1c3c57a94e07f
Author: Hussein Awala <[email protected]>
AuthorDate: Thu Aug 31 10:22:55 2023 +0200
Replace sequence concatination by unpacking in Airflow tests (#33935)
---
tests/cli/commands/test_task_command.py | 2 +-
tests/dag_processing/test_job_runner.py | 2 +-
tests/providers/amazon/aws/hooks/test_eks.py | 12 ++++++------
.../providers/google/cloud/operators/test_datafusion.py | 2 +-
tests/providers/google/cloud/operators/test_dataproc.py | 16 ++++++++++------
tests/serialization/test_dag_serialization.py | 4 ++--
tests/utils/test_helpers.py | 4 ++--
tests/utils/test_python_virtualenv.py | 2 +-
8 files changed, 24 insertions(+), 20 deletions(-)
diff --git a/tests/cli/commands/test_task_command.py
b/tests/cli/commands/test_task_command.py
index c7937fa93f..19100bb5af 100644
--- a/tests/cli/commands/test_task_command.py
+++ b/tests/cli/commands/test_task_command.py
@@ -816,7 +816,7 @@ class TestLogsfromTaskRunCommand:
session.commit()
assert
session.query(TaskInstance).filter_by(pool=pool_name).first() is None
- task_command.task_run(self.parser.parse_args(self.task_args +
["--pool", pool_name]))
+ task_command.task_run(self.parser.parse_args([*self.task_args,
"--pool", pool_name]))
assert
session.query(TaskInstance).filter_by(pool=pool_name).first() is not None
session.delete(pool)
diff --git a/tests/dag_processing/test_job_runner.py
b/tests/dag_processing/test_job_runner.py
index 8189c9a219..481b740ca6 100644
--- a/tests/dag_processing/test_job_runner.py
+++ b/tests/dag_processing/test_job_runner.py
@@ -499,7 +499,7 @@ class TestDagProcessorJobRunner:
["file_3.py", "file_2.py", "file_1.py"]
)
- manager.processor.set_file_paths(dag_files + ["file_4.py"])
+ manager.processor.set_file_paths([*dag_files, "file_4.py"])
manager.processor.add_new_file_path_to_queue()
assert manager.processor._file_path_queue == collections.deque(
["file_4.py", "file_3.py", "file_2.py", "file_1.py"]
diff --git a/tests/providers/amazon/aws/hooks/test_eks.py
b/tests/providers/amazon/aws/hooks/test_eks.py
index 6b841e78c6..d842a69a61 100644
--- a/tests/providers/amazon/aws/hooks/test_eks.py
+++ b/tests/providers/amazon/aws/hooks/test_eks.py
@@ -1170,15 +1170,15 @@ class TestEksHooks:
test_inputs = dict(
deepcopy(
- # Required Constants
- [POD_EXECUTION_ROLE_ARN]
- # Required Variables
- + [
+ [
+ # Required Constants
+ POD_EXECUTION_ROLE_ARN,
+ # Required Variables
(ClusterAttributes.CLUSTER_NAME, cluster_name),
(FargateProfileAttributes.FARGATE_PROFILE_NAME,
fargate_profile_name),
+ # Test Case Values
+ (FargateProfileAttributes.SELECTORS, selectors),
]
- # Test Case Values
- + [(FargateProfileAttributes.SELECTORS, selectors)]
)
)
diff --git a/tests/providers/google/cloud/operators/test_datafusion.py
b/tests/providers/google/cloud/operators/test_datafusion.py
index 2950fceb7d..fd5ed2d648 100644
--- a/tests/providers/google/cloud/operators/test_datafusion.py
+++ b/tests/providers/google/cloud/operators/test_datafusion.py
@@ -238,7 +238,7 @@ class TestCloudDataFusionStartPipelineOperator:
)
mock_hook.return_value.wait_for_pipeline_state.assert_called_once_with(
- success_states=SUCCESS_STATES + [PipelineStates.RUNNING],
+ success_states=[*SUCCESS_STATES, PipelineStates.RUNNING],
pipeline_id=PIPELINE_ID,
pipeline_name=PIPELINE_NAME,
namespace=NAMESPACE,
diff --git a/tests/providers/google/cloud/operators/test_dataproc.py
b/tests/providers/google/cloud/operators/test_dataproc.py
index 923a7abae6..40180d4b47 100644
--- a/tests/providers/google/cloud/operators/test_dataproc.py
+++ b/tests/providers/google/cloud/operators/test_dataproc.py
@@ -474,7 +474,8 @@ class
TestDataprocClusterCreateOperator(DataprocClusterTestBase):
"labels": LABELS,
"virtual_cluster_config": None,
}
- expected_calls = self.extra_links_expected_calls_base + [
+ expected_calls = [
+ *self.extra_links_expected_calls_base,
call.hook().create_cluster(**create_cluster_args),
]
@@ -523,7 +524,8 @@ class
TestDataprocClusterCreateOperator(DataprocClusterTestBase):
"labels": LABELS,
"virtual_cluster_config": VIRTUAL_CLUSTER_CONFIG,
}
- expected_calls = self.extra_links_expected_calls_base + [
+ expected_calls = [
+ *self.extra_links_expected_calls_base,
call.hook().create_cluster(**create_cluster_args),
]
@@ -811,8 +813,9 @@ class
TestDataprocClusterScaleOperator(DataprocClusterTestBase):
"graceful_decommission_timeout": {"seconds": 600},
"update_mask": UPDATE_MASK,
}
- expected_calls = self.extra_links_expected_calls_base + [
- call.hook().update_cluster(**update_cluster_args)
+ expected_calls = [
+ *self.extra_links_expected_calls_base,
+ call.hook().update_cluster(**update_cluster_args),
]
op = DataprocScaleClusterOperator(
@@ -1256,8 +1259,9 @@ class
TestDataprocUpdateClusterOperator(DataprocClusterTestBase):
"timeout": TIMEOUT,
"metadata": METADATA,
}
- expected_calls = self.extra_links_expected_calls_base + [
- call.hook().update_cluster(**update_cluster_args)
+ expected_calls = [
+ *self.extra_links_expected_calls_base,
+ call.hook().update_cluster(**update_cluster_args),
]
op = DataprocUpdateClusterOperator(
diff --git a/tests/serialization/test_dag_serialization.py
b/tests/serialization/test_dag_serialization.py
index 2c2bf2d6f3..061a1531ec 100644
--- a/tests/serialization/test_dag_serialization.py
+++ b/tests/serialization/test_dag_serialization.py
@@ -1472,7 +1472,7 @@ class TestStringifiedDAGs:
pass
class DummyTask(BaseOperator):
- deps = frozenset(list(BaseOperator.deps) + [DummyTriggerRule()])
+ deps = frozenset([*BaseOperator.deps, DummyTriggerRule()])
execution_date = datetime(2020, 1, 1)
with DAG(dag_id="test_error_on_unregistered_ti_dep_serialization",
start_date=execution_date) as dag:
@@ -1499,7 +1499,7 @@ class TestStringifiedDAGs:
from test_plugin import CustomTestTriggerRule
class DummyTask(BaseOperator):
- deps = frozenset(list(BaseOperator.deps) +
[CustomTestTriggerRule()])
+ deps = frozenset([*BaseOperator.deps, CustomTestTriggerRule()])
execution_date = datetime(2020, 1, 1)
with DAG(dag_id="test_serialize_custom_ti_deps",
start_date=execution_date) as dag:
diff --git a/tests/utils/test_helpers.py b/tests/utils/test_helpers.py
index c3c370060a..46462c30d1 100644
--- a/tests/utils/test_helpers.py
+++ b/tests/utils/test_helpers.py
@@ -80,9 +80,9 @@ class TestHelpers:
assert list(helpers.chunks([1, 2, 3], 2)) == [[1, 2], [3]]
def test_reduce_in_chunks(self):
- assert helpers.reduce_in_chunks(lambda x, y: x + [y], [1, 2, 3, 4, 5],
[]) == [[1, 2, 3, 4, 5]]
+ assert helpers.reduce_in_chunks(lambda x, y: [*x, y], [1, 2, 3, 4, 5],
[]) == [[1, 2, 3, 4, 5]]
- assert helpers.reduce_in_chunks(lambda x, y: x + [y], [1, 2, 3, 4, 5],
[], 2) == [[1, 2], [3, 4], [5]]
+ assert helpers.reduce_in_chunks(lambda x, y: [*x, y], [1, 2, 3, 4, 5],
[], 2) == [[1, 2], [3, 4], [5]]
assert helpers.reduce_in_chunks(lambda x, y: x + y[0] * y[1], [1, 2,
3, 4], 0, 2) == 14
diff --git a/tests/utils/test_python_virtualenv.py
b/tests/utils/test_python_virtualenv.py
index ea11f979d7..9f1385b61e 100644
--- a/tests/utils/test_python_virtualenv.py
+++ b/tests/utils/test_python_virtualenv.py
@@ -96,7 +96,7 @@ class TestPrepareVirtualenv:
[sys.executable, "-m", "virtualenv", "/VENV",
"--system-site-packages", "--python=pythonVER"]
)
mock_execute_in_subprocess.assert_called_with(
- ["/VENV/bin/pip", "install"] + pip_install_options +
["apache-beam[gcp]"]
+ ["/VENV/bin/pip", "install", *pip_install_options,
"apache-beam[gcp]"]
)
@mock.patch("airflow.utils.python_virtualenv.execute_in_subprocess")