from contextlib import redirect_stdout
from datetime import timedelta
from pathlib import Path
from tempfile import NamedTemporaryFile
from unittest import mock
from unittest.mock import patch
import jinja2
import pendulum
import pytest
import time_machine
from dateutil.relativedelta import relativedelta
from sqlalchemy import inspect
import airflow
from airflow import models, settings
from airflow.configuration import conf
from airflow.datasets import Dataset
from airflow.decorators import setup, task as task_decorator, teardown
from airflow.exceptions import (
    AirflowException,
    DuplicateTaskIdFound,
    ParamValidationError,
    RemovedInAirflow3Warning,
)
from airflow.models import DAG, DagModel, DagRun, DagTag, TaskFail, TaskInstance as TI
from airflow.models.baseoperator import BaseOperator
from airflow.models.dag import DagOwnerAttributes, dag as dag_decorator, get_dataset_triggered_next_run_info
from airflow.models.dataset import DatasetDagRunQueue, DatasetEvent, DatasetModel, TaskOutletDatasetReference
from airflow.models.param import DagParam, Param, ParamsDict
from airflow.models.serialized_dag import SerializedDagModel
from airflow.operators.bash import BashOperator