@@ -25,20 +25,24 @@ def db_config() -> DatabaseConfig:
25
25
26
26
27
27
@pytest_asyncio .fixture (loop_scope = "session" , scope = "session" )
28
- async def static_test_db_pool (db_config : DatabaseConfig ) -> AsyncGenerator [Pool ]:
28
+ async def static_test_db_pool (db_config : DatabaseConfig ) -> AsyncGenerator [Pool , None ]:
29
29
pool = await create_db_pool (cfg = db_config , n_connections = 10 )
30
30
yield pool
31
31
await pool .close ()
32
32
33
33
34
34
@pytest_asyncio .fixture (loop_scope = "session" , scope = "function" )
35
- async def test_db (db_config : DatabaseConfig , static_test_db_pool : Pool ) -> AsyncGenerator [Database ]:
35
+ async def test_db (
36
+ db_config : DatabaseConfig , static_test_db_pool : Pool
37
+ ) -> AsyncGenerator [Database , None ]:
36
38
dbname = "" .join (random .choices (string .ascii_lowercase , k = 20 ))
37
39
cfg = db_config .model_copy ()
38
40
cfg .dbname = dbname
39
41
await static_test_db_pool .execute (f'create database "{ dbname } "' )
40
42
if db_config .user :
41
- await static_test_db_pool .execute (f'alter database "{ dbname } " owner to "{ db_config .user } "' )
43
+ await static_test_db_pool .execute (
44
+ f'alter database "{ dbname } " owner to "{ db_config .user } "'
45
+ )
42
46
mininal_db_assets = ASSETS_DIR / "minimal_db"
43
47
database = Database (
44
48
config = cfg ,
@@ -51,14 +55,14 @@ async def test_db(db_config: DatabaseConfig, static_test_db_pool: Pool) -> Async
51
55
52
56
53
57
@pytest_asyncio .fixture (loop_scope = "session" , scope = "function" )
54
- async def test_db_pool (test_db : Database ) -> AsyncGenerator [Pool ]:
58
+ async def test_db_pool (test_db : Database ) -> AsyncGenerator [Pool , None ]:
55
59
pool = await test_db .create_pool (n_connections = 10 )
56
60
yield pool
57
61
await pool .close ()
58
62
59
63
60
64
@pytest_asyncio .fixture (loop_scope = "session" , scope = "function" )
61
- async def test_db_conn (test_db_pool : Pool ) -> AsyncGenerator [Connection ]:
65
+ async def test_db_conn (test_db_pool : Pool ) -> AsyncGenerator [Connection , None ]:
62
66
async with test_db_pool .acquire () as conn :
63
67
yield conn
64
68
0 commit comments