MCPcopy
hub / github.com/psycopg/psycopg / test_cancel_safe_error

Function test_cancel_safe_error

tests/test_connection.py:900–914  ·  view source on GitHub ↗
(conn_cls, proxy, caplog)

Source from the content-addressed store, hash-verified

898@pytest.mark.slow
899@pytest.mark.timing
900def test_cancel_safe_error(conn_cls, proxy, caplog):
901 caplog.set_level(logging.WARNING, logger="psycopg")
902 proxy.start()
903 with conn_cls.connect(proxy.client_dsn) as conn:
904 proxy.stop()
905 with pytest.raises(
906 e.OperationalError, match="(Connection refused)|(connect\\(\\) failed)"
907 ) as ex:
908 conn.cancel_safe(timeout=2)
909 assert not caplog.records
910
911 # Note: testing an internal method. It's ok if this behaviour changes
912 conn._try_cancel(timeout=2.0)
913 assert len(caplog.records) == 1
914 caplog.records[0].message == str(ex.value)
915
916
917@pytest.mark.slow

Callers

nothing calls this directly

Calls 5

startMethod · 0.45
connectMethod · 0.45
stopMethod · 0.45
cancel_safeMethod · 0.45
_try_cancelMethod · 0.45

Tested by

no test coverage detected