insomnes commented on code in PR #47407:
URL: https://github.com/apache/airflow/pull/47407#discussion_r1984665186
##########
task_sdk/tests/execution_time/test_task_runner.py:
##########
@@ -1153,10 +1160,12 @@ def execute(self, context):
run(runtime_ti, log=mock.MagicMock())
- if isinstance(task_ids, str):
+ if not isinstance(task_ids, Iterable) or isinstance(task_ids, str):
task_ids = [task_ids]
for task_id in task_ids:
+ if task_id is None or isinstance(task_id, ArgNotSet):
+ task_id = runtime_ti.task_id
Review Comment:
I am not sure if it would be reasonable to provide it inside parametrized
params, cause it's static (at least as I see it). The resulting test code is
very verbose without extra clarity in my view.
But the reliance on `runtime_ti` behavior is for sure undesired here. I've
extracted `task_id` used in the operator variable and set our expected
`task_id` to this variable. I believe that is in alignment with the spirit of
your comment.
If I misunderstood your idea, I am sorry for the inconvenience, feel free to
insist on it.
I have an initial variant with the pytest parameterize. Would it be ok, then?
```python
@pytest.mark.parametrize(
"task_ids, rewrite_task_id",
[
["push_task", None],
[["push_task1", "push_task2"], None],
[{"push_task1", "push_task2"}, None],
[None, "special_task_id"],
[NOTSET, "special_task_id"],
],
)
def test_xcom_pull(self, create_runtime_ti, mock_supervisor_comms,
spy_agency, task_ids, rewrite_task_id):
....
test_task_id = "pull_task" if rewrite_task_id is None else
rewrite_task_id
task = CustomOperator(task_id=test_task_id)
....
for task_id in task_ids:
if rewrite_task_id is not None:
task_id = rewrite_task_id
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]