1313# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414# See the License for the specific language governing permissions and
1515# limitations under the License.
16+ import sys
1617import atheris
1718import colorlog
1819from datetime import datetime , timedelta
19- with atheris .instrument_imports ():
20+
21+ with atheris .instrument_imports (include = ['airflow' ], enable_loader_override = False ):
2022 import airflow
2123 from airflow import DAG
2224 from airflow .exceptions import AirflowException
23- from airflow .operators .dummy_operator import DummyOperator
24- from airflow .operators .python_operator import PythonOperator
25+
26+ try :
27+ from airflow .providers .standard .operators .empty import EmptyOperator as DummyOperator
28+ from airflow .providers .standard .operators .python import PythonOperator
29+ except ImportError :
30+ try :
31+ from airflow .operators .empty import EmptyOperator as DummyOperator
32+ from airflow .operators .python import PythonOperator
33+ except ImportError :
34+ from airflow .operators .dummy_operator import DummyOperator
35+ from airflow .operators .python_operator import PythonOperator
2536
2637def py_func ():
2738 return
@@ -32,7 +43,7 @@ def TestInput(input_bytes):
3243 default_args = {
3344 'owner' : fdp .ConsumeString (8 ),
3445 'depends_on_past' : fdp .ConsumeBool (),
35- 'start_date' : airflow . utils . dates . days_ago ( fdp .ConsumeIntInRange (1 ,5 )),
46+ 'start_date' : datetime . now () - timedelta ( days = fdp .ConsumeIntInRange (1 ,5 )),
3647 'email' : [fdp .ConsumeString (8 )],
3748 'email_on_failure' : fdp .ConsumeBool (),
3849 'email_on_retry' : fdp .ConsumeBool (),
@@ -46,7 +57,7 @@ def TestInput(input_bytes):
4657 python_task = PythonOperator (task_id = fdp .ConsumeString (8 ), python_callable = py_func )
4758
4859 dummy_task >> python_task
49- except AirflowException :
60+ except ( AirflowException , ValueError , TypeError ) :
5061 pass
5162
5263def main ():
0 commit comments