]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Tests: Create svcconn with autocommit on
authorDaniel Fortunov <github@danielfortunov.com>
Sun, 26 Jul 2020 01:37:02 +0000 (02:37 +0100)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sat, 8 Aug 2020 20:21:43 +0000 (21:21 +0100)
So that you don't deadlock the test run if you forget to call commit()

e.g. If you use svcconn to create a test table for use by tests, and
forget to call svcconn.commit(), the first test to (try to) touch the
table will block forever waiting on the svcconn transaction to commit.

tests/fix_db.py
tests/test_cursor.py
tests/test_cursor_async.py
tests/types/test_composite.py

index f17f16e0b170852b326dbbe5685b129f76fc6827..039bc1be0194acc51b9bc6c786b4298760b213fa 100644 (file)
@@ -62,6 +62,6 @@ def svcconn(dsn):
     """
     from psycopg3 import Connection
 
-    conn = Connection.connect(dsn)
+    conn = Connection.connect(dsn, autocommit=True)
     yield conn
     conn.close()
index f1ada858845cc91e44ac5e3e6a2b7c50e8be7347..befd7f3f41a35a3488fdae975398e0221b7cb994 100644 (file)
@@ -123,14 +123,12 @@ def _execmany(svcconn):
         create table execmany (id serial primary key, num integer, data text)
         """
     )
-    svcconn.commit()
 
 
 @pytest.fixture(scope="function")
 def execmany(svcconn, _execmany):
     cur = svcconn.cursor()
     cur.execute("truncate table execmany")
-    svcconn.commit()
 
 
 def test_executemany(conn, execmany):
index 715d2027d20d538d55ab897620c9a6c7011fe7d9..9168ddecf2c9af42eaa9c5e941d5a3fdc40771fe 100644 (file)
@@ -126,7 +126,6 @@ async def execmany(svcconn):
         create table execmany (id serial primary key, num integer, data text)
         """
     )
-    svcconn.commit()
 
 
 async def test_executemany(aconn, execmany):
index 71accd0ec0eadb21d2910a29ce20ee620cf40dd9..d61e681e30740188b406a45e5cbafc7240e30628 100644 (file)
@@ -99,7 +99,6 @@ def testcomp(svcconn):
         create type testcomp as (foo text, bar int8, baz float8);
         """
     )
-    svcconn.commit()
 
 
 def test_fetch_info(conn, testcomp):