File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed
providers/standard/tests/unit/standard/operators Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change 2121
2222from __future__ import annotations
2323
24+ import os
2425from http import HTTPStatus
2526from typing import TYPE_CHECKING , NamedTuple
2627
2728if TYPE_CHECKING :
2829 from airflow .models import DagRun
2930
30- from airflow .sdk .exceptions import AirflowException , AirflowNotFoundException
31+ # When _AIRFLOW__AS_LIBRARY is set, airflow.sdk may not be installed
32+ # In that case, we define fallback exception classes
33+ if os .environ .get ("_AIRFLOW__AS_LIBRARY" ):
34+ try :
35+ from airflow .sdk .exceptions import AirflowException , AirflowNotFoundException
36+ except ImportError :
37+ # Fallback exception classes when airflow.sdk is not installed
38+ class AirflowException (RuntimeError ):
39+ """Base exception for Airflow errors."""
40+
41+ pass
42+
43+ class AirflowNotFoundException (AirflowException ):
44+ """Raise when a requested object is not found."""
45+
46+ pass
47+ else :
48+ from airflow .sdk .exceptions import AirflowException , AirflowNotFoundException
3149
3250
3351class TaskNotFound (AirflowException ):
Original file line number Diff line number Diff line change @@ -112,7 +112,7 @@ def test_no_target_time(self):
112112 """Check if BranchDateTimeOperator raises exception on missing target"""
113113 with pytest .raises (AirflowException ):
114114 BranchDateTimeOperator (
115- task_id = "datetime_branch_2 " ,
115+ task_id = "datetime_branch " ,
116116 follow_task_ids_if_true = "branch_1" ,
117117 follow_task_ids_if_false = "branch_2" ,
118118 target_upper = None ,
You can’t perform that action at this time.
0 commit comments