]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Pass 'dsn' value to ConnectionPool in tests
authorDenis Laxalde <denis.laxalde@dalibo.com>
Thu, 15 Apr 2021 14:19:10 +0000 (16:19 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Fri, 16 Apr 2021 11:28:56 +0000 (12:28 +0100)
Otherwise, those tests fail when there's no database named after current
user (typically, 'connection failed: database "denis" does not exist').

tests/pool/test_pool.py

index dae0f04605bb4f949fc9065a3e39251461ae7f12..6f42b7f0a0b6f23583b255a284a1fd4183310f17 100644 (file)
@@ -146,7 +146,7 @@ def test_configure(dsn):
         with conn.transaction():
             conn.execute("set default_transaction_read_only to on")
 
-    with pool.ConnectionPool(min_size=1, configure=configure) as p:
+    with pool.ConnectionPool(dsn, min_size=1, configure=configure) as p:
         p.wait(timeout=1.0)
         with p.connection() as conn:
             assert inits == 1
@@ -172,7 +172,7 @@ def test_configure_badstate(dsn, caplog):
     def configure(conn):
         conn.execute("select 1")
 
-    with pool.ConnectionPool(min_size=1, configure=configure) as p:
+    with pool.ConnectionPool(dsn, min_size=1, configure=configure) as p:
         with pytest.raises(pool.PoolTimeout):
             p.wait(timeout=0.5)
 
@@ -188,7 +188,7 @@ def test_configure_broken(dsn, caplog):
         with conn.transaction():
             conn.execute("WAT")
 
-    with pool.ConnectionPool(min_size=1, configure=configure) as p:
+    with pool.ConnectionPool(dsn, min_size=1, configure=configure) as p:
         with pytest.raises(pool.PoolTimeout):
             p.wait(timeout=0.5)
 
@@ -209,7 +209,7 @@ def test_reset(dsn):
         with conn.transaction():
             conn.execute("set timezone to utc")
 
-    with pool.ConnectionPool(min_size=1, reset=reset) as p:
+    with pool.ConnectionPool(dsn, min_size=1, reset=reset) as p:
         with p.connection() as conn:
             assert resets == 0
             conn.execute("set timezone to '+2:00'")
@@ -231,7 +231,7 @@ def test_reset_badstate(dsn, caplog):
     def reset(conn):
         conn.execute("reset all")
 
-    with pool.ConnectionPool(min_size=1, reset=reset) as p:
+    with pool.ConnectionPool(dsn, min_size=1, reset=reset) as p:
         with p.connection() as conn:
             conn.execute("select 1")
             pid1 = conn.pgconn.backend_pid
@@ -252,7 +252,7 @@ def test_reset_broken(dsn, caplog):
         with conn.transaction():
             conn.execute("WAT")
 
-    with pool.ConnectionPool(min_size=1, reset=reset) as p:
+    with pool.ConnectionPool(dsn, min_size=1, reset=reset) as p:
         with p.connection() as conn:
             conn.execute("select 1")
             pid1 = conn.pgconn.backend_pid