MCPcopy
hub / github.com/psycopg/psycopg / tracefile

Function tracefile

tests/fix_db.py:125–145  ·  view source on GitHub ↗

Open and yield a file for libpq client/server communication traces if --pq-tracefile option is set.

(request)

Source from the content-addressed store, hash-verified

123
124@pytest.fixture(scope="session")
125def tracefile(request):
126 """Open and yield a file for libpq client/server communication traces if
127 --pq-tracefile option is set.
128 """
129 if not (tracefile := request.config.getoption("--pq-trace")):
130 yield None
131 return
132
133 if tracefile.lower() == "stderr":
134 try:
135 sys.stderr.fileno()
136 except io.UnsupportedOperation:
137 raise pytest.UsageError(
138 "cannot use stderr for --pq-trace (in-memory file?)"
139 ) from None
140
141 yield sys.stderr
142 return
143
144 with open(tracefile, "w") as f:
145 yield f
146
147
148@contextmanager

Callers

nothing calls this directly

Calls 2

lowerMethod · 0.80
filenoMethod · 0.80

Tested by

no test coverage detected