3131
3232
3333# DSNs for different databases
34- SQLITE_TEST_DSN = 'sqlite+aiosqlite:///file::memory:?cache=shared'
35- # SQLITE_TEST_DSN_FILE = "sqlite+aiosqlite:///./test_param.db" # For file-based SQLite inspection
34+ SQLITE_TEST_DSN = (
35+ 'sqlite+aiosqlite:///file:testdb?mode=memory&cache=shared&uri=true'
36+ )
3637POSTGRES_TEST_DSN = os .environ .get (
3738 'POSTGRES_TEST_DSN'
3839) # e.g., "postgresql+asyncpg://user:pass@host:port/dbname"
8586)
8687
8788
88- @pytest .fixture (scope = 'session' , autouse = True )
89- def cleanup_sqlite_files ():
90- """Clean up SQLite file::memory: files created during tests."""
91- yield
92-
93- sqlite_memory_file = Path ('file::memory:' )
94- if sqlite_memory_file .exists ():
95- try :
96- sqlite_memory_file .unlink ()
97- except Exception :
98- pass
99-
100-
10189@pytest_asyncio .fixture (params = DB_CONFIGS )
10290async def db_store_parameterized (
10391 request ,
@@ -111,11 +99,6 @@ async def db_store_parameterized(
11199 if db_url is None :
112100 pytest .skip (f'DSN for { dialect_name } not set in environment variables.' )
113101
114- # Ensure the path for file-based SQLite exists if that DSN is used
115- # if "sqlite" in db_url and "memory" not in db_url:
116- # db_file_path = db_url.split("///")[-1]
117- # os.makedirs(os.path.dirname(db_file_path), exist_ok=True)
118-
119102 engine = create_async_engine (db_url )
120103 store = None # Initialize store to None for the finally block
121104
@@ -138,14 +121,6 @@ async def db_store_parameterized(
138121 await conn .run_sync (Base .metadata .drop_all )
139122 await engine .dispose () # Dispose the engine created in the fixture
140123
141- if dialect_name == 'sqlite' :
142- sqlite_memory_file = Path ('file::memory:' )
143- if sqlite_memory_file .exists ():
144- try :
145- sqlite_memory_file .unlink ()
146- except Exception :
147- pass
148-
149124
150125@pytest .mark .asyncio
151126async def test_initialize_creates_table (
0 commit comments