You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/08/17 13:24:52 UTC
[GitHub] [airflow] ashb commented on a change in pull request #17577: Have the dag_maker fixture (optionally) give SerializedDAGs
ashb commented on a change in pull request #17577:
URL: https://github.com/apache/airflow/pull/17577#discussion_r690367118
##########
File path: tests/conftest.py
##########
@@ -451,49 +451,88 @@ def dag_maker(request):
The dag_maker.create_dagrun takes the same arguments as dag.create_dagrun
+ If you want to operate on serialized DAGs, then either pass ``serialized=True` to the ``dag_maker()``
+ call, or you can mark your test/class/file with ``@pytest.mark.need_serialized_dag(True)``. In both of
+ these cases the ``dag`` returned by the context manager will be a lazily-evaluated proxy object to the
+ SerializedDAG.
"""
- from airflow.models import DAG, DagModel
- from airflow.utils import timezone
- from airflow.utils.session import provide_session
- from airflow.utils.state import State
+ import lazy_object_proxy
- DEFAULT_DATE = timezone.datetime(2016, 1, 1)
+ # IMPORTANT: Delay _all_ imports from `airflow.*` to _inside a method_.
+ # This fixture is "called" early on in the pytest collection process, and
+ # if we import airflow.* here the wrong (non-test) config will be loaded
+ # and "baked" in to various constants
+
+ want_serialized = False
+
+ # Allow changing default serialized behaviour with `@ptest.mark.need_serialized_dag(True)`
Review comment:
We don't, good call.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org