We're testing our operators with something along these lines:

with DAG(dag_id='anydag', start_date=datetime.now()) as dag:
    operator = MyOperator(task_id='test_task')
    ti = TaskInstance(task=operator, execution_date=datetime.now())
    context = ti.get_template_context()
    operator.execute(context)


MyOperator reads XCom data from its context. Is there a way to set the XCom
data in the test before executing the operator?
Is there a simpler way to test the operator without setting up DAG and task
instance?

Thanks,

Reply via email to