Skip to content

Commit

Permalink
Ensure that airflow modules are not imported too early in conftest (#…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
ashb authored Aug 23, 2021
1 parent 6301faa commit 5f159cb
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

# 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")
Expand Down

0 comments on commit 5f159cb

Please sign in to comment.