diff --git a/airflow-core/docs/best-practices.rst b/airflow-core/docs/best-practices.rst index 2a3be332d16b6..724398c9f8277 100644 --- a/airflow-core/docs/best-practices.rst +++ b/airflow-core/docs/best-practices.rst @@ -852,7 +852,7 @@ You can use environment variables to parameterize the Dag. Mocking variables and connections ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -When you write tests for code that uses variables or a connection, you must ensure that they exist when you run the tests. The obvious solution is to save these objects to the database so they can be read while your code is executing. However, reading and writing objects to the database are burdened with additional time overhead. In order to speed up the test execution, it is worth simulating the existence of these objects without saving them to the database. For this, you can create environment variables with mocking :any:`os.environ` using :meth:`unittest.mock.patch.dict`. +When you write tests for code that uses variables or a connection, you must ensure that they exist when you run the tests. The obvious solution is to save these objects to the database so they can be read while your code is executing. However, reading and writing objects to the database are burdened with additional time overhead. In order to speed up the test execution, it is worth simulating the existence of these objects without saving them to the database. For this, you can create environment variables with mocking :data:`os.environ` using :meth:`unittest.mock.patch.dict`. For variable, use :envvar:`AIRFLOW_VAR_{KEY}`.