potiuk commented on code in PR #58969:
URL: https://github.com/apache/airflow/pull/58969#discussion_r2616930317


##########
airflow-core/docs/best-practices.rst:
##########
@@ -650,6 +650,104 @@ want to optimize your Dags there are the following 
actions you can take:
 Testing a Dag
 ^^^^^^^^^^^^^
 
+Testing Operators with pytest
+-----------------------------
+
+Below are two recommended, runnable patterns for unit-testing custom operators
+with pytest. Both examples work with Airflow 3.x.
+
+1. Using ``TaskInstance.run()``
+2. Using ``dag.create_dagrun()``
+
+Example: Using ``EmptyOperator``
+
+    from airflow.operators.empty import EmptyOperator
+
+    task = EmptyOperator(task_id="empty_task")
+
+
+Example 1: Testing using ``TaskInstance.run()``
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+This pattern constructs a DAG, creates a ``TaskInstance`` manually,

Review Comment:
   ```suggestion
   This pattern constructs a Dag, creates a ``TaskInstance`` manually,
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to