Skip to content

dag.test not working in Airflow 3 #51018

@collinmcnulty

Description

@collinmcnulty

Apache Airflow version

3.0.1

If "Other Airflow 2 version" selected, which one?

No response

What happened?

DAG as imported from airflow.sdk does not implement test() even though airflow.models.DAG does. This means that you can't actually run dag.test.

What you think should happen instead?

airflow.sdk.DAG should implement test and it should behave the same as Airflow 2.

How to reproduce

Here is minimal DAG:

import logging

from pendulum.datetime import DateTime

from airflow.decorators import dag, task


@dag(
    schedule=None,
    start_date=DateTime.create(2024, 1, 1, tz="UTC"),
)
def minimal_dag():
    @task.python
    def hello(params) -> str | None:
        logging.info("hello")

    hello()


minimal = minimal_dag()


if __name__ == "__main__":
    minimal.test()

And the resulting error

Traceback (most recent call last):
  File "<omitted>/airflow/dags/example.py", line 28, in <module>
    minimal.test()
    ^^^^^^^^^^^^
AttributeError: 'DAG' object has no attribute 'test'

### Operating System

Mac OS 18.5

### Versions of Apache Airflow Providers

None relevant

### Deployment

Virtualenv installation

### Deployment details

_No response_

### Anything else?

I verified that the same DAGs were working with dag.test on Airflow 2.10.4

### Are you willing to submit PR?

- [ ] Yes I am willing to submit a PR!

### Code of Conduct

- [x] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:corekind:bugThis is a clearly a bugneeds-triagelabel for new issues that we didn't triage yetpriority:mediumBug that should be fixed before next release but would not block a release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions