| 644 | @pytest.mark.libpq(">= 14") |
| 645 | @pytest.mark.skipif("sys.platform != 'linux'") |
| 646 | def 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'") |