MCPcopy
hub / github.com/psycopg/psycopg / test_inerror_rollback

Function test_inerror_rollback

tests/pool/test_pool_null.py:303–329  ·  view source on GitHub ↗
(dsn, caplog)

Source from the content-addressed store, hash-verified

301
302@pytest.mark.crdb_skip("backend pid")
303def test_inerror_rollback(dsn, caplog):
304 caplog.set_level(logging.WARNING, logger="psycopg.pool")
305 pids = []
306
307 def worker():
308 with p.connection() as conn:
309 pids.append(conn.info.backend_pid)
310 assert conn.info.transaction_status == TransactionStatus.IDLE
311
312 with pool.NullConnectionPool(dsn, max_size=1) as p:
313 conn = p.getconn()
314
315 # Queue the worker so it will take the connection a second time instead
316 # of making a new one.
317 t = spawn(worker)
318 ensure_waiting(p)
319
320 pids.append(conn.info.backend_pid)
321 with pytest.raises(psycopg.ProgrammingError):
322 conn.execute("wat")
323 assert conn.info.transaction_status == TransactionStatus.INERROR
324 p.putconn(conn)
325 gather(t)
326
327 assert pids[0] == pids[1]
328 assert len(caplog.records) == 1
329 assert "INERROR" in caplog.records[0].message
330
331
332@pytest.mark.crdb_skip("backend pid")

Callers

nothing calls this directly

Calls 6

ensure_waitingFunction · 0.70
spawnFunction · 0.50
gatherFunction · 0.50
getconnMethod · 0.45
executeMethod · 0.45
putconnMethod · 0.45

Tested by

no test coverage detected