MCPcopy
hub / github.com/psycopg/psycopg / test_trace

Function test_trace

tests/pq/test_pgconn.py:646–661  ·  view source on GitHub ↗
(pgconn, tmp_path)

Source from the content-addressed store, hash-verified

644@pytest.mark.libpq(">= 14")
645@pytest.mark.skipif("sys.platform != 'linux'")
646def test_trace(pgconn, tmp_path):
647 tracef = tmp_path / "trace"
648 with tracef.open("w") as f:
649 pgconn.trace(f.fileno())
650 pgconn.set_trace_flags(pq.Trace.SUPPRESS_TIMESTAMPS | pq.Trace.REGRESS_MODE)
651 pgconn.exec_(b"select 1::int4 as foo")
652 pgconn.untrace()
653 pgconn.exec_(b"select 2::int4 as foo")
654 traces = [line.split("\t") for line in tracef.read_text().splitlines()]
655 assert traces == [
656 ["F", "26", "Query", ' "select 1::int4 as foo"'],
657 ["B", "28", "RowDescription", ' 1 "foo" NNNN 0 NNNN 4 -1 0'],
658 ["B", "11", "DataRow", " 1 1 '1'"],
659 ["B", "13", "CommandComplete", ' "SELECT 1"'],
660 ["B", "5", "ReadyForQuery", " I"],
661 ]
662
663
664@pytest.mark.skipif("sys.platform == 'linux'")

Callers

nothing calls this directly

Calls 6

filenoMethod · 0.80
openMethod · 0.45
traceMethod · 0.45
set_trace_flagsMethod · 0.45
exec_Method · 0.45
untraceMethod · 0.45

Tested by

no test coverage detected