This is an automated email from the ASF dual-hosted git repository.
ash pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 5f159cb Ensure that airflow modules are not imported too early in
conftest (#17779)
5f159cb is described below
commit 5f159cb2c607b9c9b50adc142b20bacc59957af8
Author: Ash Berlin-Taylor <[email protected]>
AuthorDate: Mon Aug 23 13:46:38 2021 +0100
Ensure that airflow modules are not imported too early in conftest (#17779)
If someone adds `import airflow` or any submodule in to conftest it will
cause airflow.settings and airflow.configuration to be imported and
initialized before we set the test env vars -- this leads to _some_
tests failing in bizarre ways.
---
tests/conftest.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/conftest.py b/tests/conftest.py
index bcfc91f..745ec9f 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -25,6 +25,7 @@ import pytest
# We should set these before loading _any_ of the rest of airflow so that the
# unit test mode config is set as early as possible.
+assert "airflow" not in sys.modules, "No airflow module can be imported before
these lines"
tests_directory = os.path.dirname(os.path.realpath(__file__))
os.environ["AIRFLOW__CORE__DAGS_FOLDER"] = os.path.join(tests_directory,
"dags")