Here is a related SO question https://stackoverflow.com/questions/58875195/airflow-test-mode-xcom-pull-push-not-working The unverified answer is as follows
> As far as I know, "test" runs without saving anything to the metadata > database which is why when you run the puller task, you get "None" as a > result and when you actually run the DAG code, it works. You can query the > metadata database directly after testing the first task to verify this. and > Context seems to be missing here, along with xcom_push=True, we need to use > provide_context=True That's what we are going off. lewismc On 2021/07/29 16:39:02, Lewis John McGibbney <[email protected]> wrote: > Hi users@, > Say I want to unit test Task A which accepts one or more parameters. These > parameters are the outputs of some other task which I want to mock. Can > someone provide a code example of how I would do that? > We are using pytest as opposed to unittest but an example of either would be > greatly appreciated. > I studied several articles [0] [1] [2] which were informative but I think > lack the content which explains what I want to do above. > I did find the following code example [3] which I feel is on the correct > track but I am not confident. > Thanks for any consideration. > lewismc > > [0] > https://airflow.apache.org/docs/apache-airflow/stable/best-practices.html#testing-a-dag > [1] > https://blog.usejournal.com/testing-in-airflow-part-1-dag-validation-tests-dag-definition-tests-and-unit-tests-2aa94970570c > [2] > https://medium.com/@chandukavar/testing-in-airflow-part-2-integration-tests-and-end-to-end-pipeline-tests-af0555cd1a82 > [3] > https://github.com/apache/airflow/blob/main/tests/ti_deps/deps/test_dagrun_exists_dep.py >
