dag_maker, session, dag_run_state, on_failure_fail_dagrun
):
    with dag_maker():
        @teardown(on_failure_fail_dagrun=on_failure_fail_dagrun)
        def teardowntask():
            print(1)
        @teardown
        def teardowntask2():
            print(1)
        @task
        def mytask():
            print(1)
        mytask() >> teardowntask() >> teardowntask2()
    dr = dag_maker.create_dagrun()
    ti1 = dr.get_task_instance(task_id="mytask")
    td1 = dr.get_task_instance(task_id="teardowntask")
    td2 = dr.get_task_instance(task_id="teardowntask2")
    ti1.state = State.SUCCESS
    td1.state = State.FAILED
    td2.state = State.FAILED
    session.merge(ti1)
    session.merge(td1)
    session.merge(td2)
    session.flush()
    dr.update_state()
    session.flush()
    dr = session.query(DagRun).one()
    assert dr.state == dag_run_state
def test_work_task_failure_when_setup_teardown_are_successful(dag_maker, session):