wjddn279 commented on code in PR #65127:
URL: https://github.com/apache/airflow/pull/65127#discussion_r3072001862
##########
airflow-core/src/airflow/settings.py:
##########
@@ -434,6 +434,12 @@ def configure_orm(disable_connection_pool=False,
pool_class=None):
# Skip DB initialization in unit tests, if DB tests are skipped
Session = SkipDBTestsSession
engine = None
+
+ # Ensure all models are imported so SQLAlchemy can resolve
string-based relationships in tests.
+ from airflow.models import import_all_models
+
+ import_all_models()
Review Comment:
I actually think the opposite. If we add fixtures to individual tests, we'll
need to keep adding more fixtures every time a new issue arises. Python's
module import system is complex, making it unpredictable which module will be
imported in what order. Whether a fixture is needed or not would become a black
box that you can only figure out by running the tests. I believe this kind of
non-determinism in tests is risky.
Regarding the performance concern you raised — for non-DB tests to run
correctly, all airflow.models need to be imported eventually anyway (that's
exactly why we're having this issue in the first place). The only difference is
that we import them explicitly and all at once at startup — nothing more.
--
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]