uranusjr commented on a change in pull request #21261:
URL: https://github.com/apache/airflow/pull/21261#discussion_r798298723
##########
File path: tests/providers/elasticsearch/log/test_es_task_handler.py
##########
@@ -38,6 +39,19 @@
from .elasticmock import elasticmock
+def get_ti(dag_id, task_id, execution_date, create_task_instance):
+ ti = create_task_instance(
+ dag_id=dag_id,
+ task_id=task_id,
+ execution_date=execution_date,
+ dagrun_state=DagRunState.RUNNING,
+ state=TaskInstanceState.RUNNING,
+ )
+ ti.try_number = 1
+ ti.raw = False
+ return ti
Review comment:
You can but it shouldn’t be generally be needed, it’s easier to make the
fixture return a _function_ that takes arguments instead (like this one here).
I searched your changes and this implementation seems to be good enough for the
usages in this PR. You’d do
```python
@pytest.fixture()
def ti(self, create_running_task_instance):
yield create_running_task_instance(
dag_id=self.DAG_ID,
task_id=self.TASK_ID,
execution_date=self.EXECUTION_DATE,
)
clear_db_runs()
clear_db_dags()
```
--
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]