MCPcopy
hub / github.com/pytest-dev/pytest / _reopen_stdio

Function _reopen_stdio

src/_pytest/capture.py:136–148  ·  view source on GitHub ↗
(f, mode)

Source from the content-addressed store, hash-verified

134 return
135
136 def _reopen_stdio(f, mode):
137 if not hasattr(stream.buffer, "raw") and mode[0] == "w":
138 buffering = 0
139 else:
140 buffering = -1
141
142 return io.TextIOWrapper(
143 open(os.dup(f.fileno()), mode, buffering),
144 f.encoding,
145 f.errors,
146 f.newlines,
147 f.line_buffering,
148 )
149
150 sys.stdin = _reopen_stdio(sys.stdin, "rb")
151 sys.stdout = _reopen_stdio(sys.stdout, "wb")

Callers 1

Calls 1

filenoMethod · 0.45

Tested by

no test coverage detected