MCPcopy
hub / github.com/psycopg/psycopg / test_right_exception_on_session_timeout

Function test_right_exception_on_session_timeout

tests/test_connection_async.py:975–990  ·  view source on GitHub ↗
(aconn)

Source from the content-addressed store, hash-verified

973@pytest.mark.slow
974@pytest.mark.crdb("skip", reason="error result not returned")
975async def test_right_exception_on_session_timeout(aconn):
976 want_ex: type[psycopg.Error] = e.IdleInTransactionSessionTimeout
977 if sys.platform == "win32":
978 # No idea why this is needed and `test_right_exception_on_server_disconnect`
979 # works instead. Maybe the difference lies in the server we are testing
980 # with, not in the client.
981 want_ex = psycopg.OperationalError
982
983 await aconn.execute("SET SESSION idle_in_transaction_session_timeout = 100")
984 await asleep(1)
985 with pytest.raises(want_ex) as ex:
986 await aconn.execute("SELECT * from pg_tables")
987
988 # This check is here to monitor if the behaviour on Window chamge.
989 # Rreceiving the same exception of other platform will be acceptable.
990 assert type(ex.value) is want_ex
991
992
993@pytest.mark.libpq(">= 14")

Callers

nothing calls this directly

Calls 2

asleepFunction · 0.70
executeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…