Skip to content

Commit

Permalink
Cleanup all sqlalchemy sessions before each test (#33190)
Browse files Browse the repository at this point in the history
Attempt to solve some of the flakiness we saw recently - this
change will run closing all opened sqlalchemy sessions before each
test. This should be a little slower than before - especially
for the very fast tests, but it provide us with much better
isolation between the tests - thus avoiding the flakiness
that we observe recently - as documented in #33178

Hopefully this one

Fixes: #33178
  • Loading branch information
potiuk authored Aug 8, 2023
1 parent 36c2735 commit 515179f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -942,3 +942,12 @@ def initialize_providers_manager():
from airflow.providers_manager import ProvidersManager

ProvidersManager().initialize_providers_configuration()


@pytest.fixture(autouse=True, scope="function")
def close_all_sqlalchemy_sessions():
from sqlalchemy.orm import close_all_sessions

close_all_sessions()
yield
close_all_sessions()

0 comments on commit 515179f

Please sign in to comment.