From: Daniel Fortunov Date: Sun, 26 Jul 2020 01:37:02 +0000 (+0100) Subject: Tests: Create svcconn with autocommit on X-Git-Tag: 3.0.dev0~462 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c814e04d321aade8354a45a1ff55ae7916e07109;p=thirdparty%2Fpsycopg.git Tests: Create svcconn with autocommit on 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. --- diff --git a/tests/fix_db.py b/tests/fix_db.py index f17f16e0b..039bc1be0 100644 --- a/tests/fix_db.py +++ b/tests/fix_db.py @@ -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() diff --git a/tests/test_cursor.py b/tests/test_cursor.py index f1ada8588..befd7f3f4 100644 --- a/tests/test_cursor.py +++ b/tests/test_cursor.py @@ -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): diff --git a/tests/test_cursor_async.py b/tests/test_cursor_async.py index 715d2027d..9168ddecf 100644 --- a/tests/test_cursor_async.py +++ b/tests/test_cursor_async.py @@ -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): diff --git a/tests/types/test_composite.py b/tests/types/test_composite.py index 71accd0ec..d61e681e3 100644 --- a/tests/types/test_composite.py +++ b/tests/types/test_composite.py @@ -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):