From e6b8af1ef413c0fd35f36983975935e28bdd8322 Mon Sep 17 00:00:00 2001 From: "unfoldci-flaky-test-autopilot[bot]" <243416357+unfoldci-flaky-test-autopilot[bot]@users.noreply.github.com> Date: Sat, 27 Dec 2025 15:18:59 +0000 Subject: [PATCH] fix: The test was flaky because it relied on the repository being initialized by previous tests. The fix ensures that the connection pool and repository are initialized within the test itself, removing the dependency on other tests. --- tests/test_isolation.py | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/tests/test_isolation.py b/tests/test_isolation.py index 0dc7efc..d50351f 100644 --- a/tests/test_isolation.py +++ b/tests/test_isolation.py @@ -172,13 +172,21 @@ async def test_03_use_repository(self): FLAKY: Depends on both test_01 and test_02 FIX: Independent setup """ - repo = TestDatabaseSetupDependency._repository - - # FLAKY: Repository might not exist - assert repo is not None, "Repository not created" - - # Would fail if pool wasn't initialized - result = await repo.find_by_id(1) + pool = TestDatabaseSetupDependency._pool + + # Ensure pool is initialized + if pool is None: + pool = ConnectionPool("test_iso_pool", min_connections=2, max_connections=5) + await pool.initialize() + + repo = TestDatabaseSetupDependency._repository + + # Ensure repository is initialized + if repo is None: + repo = Repository("users", pool) + + # Would fail if pool wasn't initialized + result = await repo.find_by_id(1) class TestCacheWarmupDependency: