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 4a982ebc2c3 Remove side-effects from test_sqlalchemy_config (#48502)
4a982ebc2c3 is described below
commit 4a982ebc2c3550e266a74bea8b7c84f33df20b9f
Author: Ash Berlin-Taylor <[email protected]>
AuthorDate: Fri Mar 28 16:35:06 2025 +0000
Remove side-effects from test_sqlalchemy_config (#48502)
The SQLA global variables we create and set up has grown over time, and in
debugging another test issue I noticed that this test was causing side
effects
in another PR
---
airflow-core/tests/unit/core/test_sqlalchemy_config.py | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/airflow-core/tests/unit/core/test_sqlalchemy_config.py
b/airflow-core/tests/unit/core/test_sqlalchemy_config.py
index befdac0f485..ac6f84cca85 100644
--- a/airflow-core/tests/unit/core/test_sqlalchemy_config.py
+++ b/airflow-core/tests/unit/core/test_sqlalchemy_config.py
@@ -33,16 +33,13 @@ pytestmark = pytest.mark.db_test
class TestSqlAlchemySettings:
- def setup_method(self):
- self.old_engine = settings.engine
- self.old_session = settings.Session
- self.old_conn = settings.SQL_ALCHEMY_CONN
+ @pytest.fixture(autouse=True, scope="class")
+ def reset(self):
settings.SQL_ALCHEMY_CONN =
"mysql+foobar://user:pass@host/dbname?inline=param&another=param"
-
- def teardown_method(self):
- settings.engine = self.old_engine
- settings.Session = self.old_session
- settings.SQL_ALCHEMY_CONN = self.old_conn
+ try:
+ yield
+ finally:
+ settings.configure_orm()
@patch("airflow.settings.setup_event_handlers")
@patch("airflow.settings.scoped_session")