MCPcopy
hub / github.com/psycopg/psycopg / test_check_connection

Function test_check_connection

tests/pool/test_pool_common.py:597–610  ·  view source on GitHub ↗
(pool_cls, conn_cls, dsn, autocommit)

Source from the content-addressed store, hash-verified

595@pytest.mark.crdb_skip("pg_terminate_backend")
596@pytest.mark.parametrize("autocommit", [True, False])
597def test_check_connection(pool_cls, conn_cls, dsn, autocommit):
598 conn = conn_cls.connect(dsn)
599 set_autocommit(conn, autocommit)
600 pool_cls.check_connection(conn)
601 assert not conn.closed
602 assert conn.info.transaction_status == psycopg.pq.TransactionStatus.IDLE
603
604 with conn_cls.connect(dsn) as conn2:
605 conn2.execute("select pg_terminate_backend(%s)", [conn.info.backend_pid])
606
607 with pytest.raises(psycopg.OperationalError):
608 pool_cls.check_connection(conn)
609
610 assert conn.closed
611
612
613def test_check_init(pool_cls, dsn):

Callers

nothing calls this directly

Calls 4

set_autocommitFunction · 0.85
connectMethod · 0.45
check_connectionMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected