MCPcopy Create free account
hub / github.com/pytest-dev/pytest / _reopen_stdio

Function _reopen_stdio

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

Source from the content-addressed store, hash-verified

106 return
107
108 def _reopen_stdio(f, mode):
109 if not buffered and mode[0] == "w":
110 buffering = 0
111 else:
112 buffering = -1
113
114 return io.TextIOWrapper(
115 open(os.dup(f.fileno()), mode, buffering), # type: ignore[arg-type]
116 f.encoding,
117 f.errors,
118 f.newlines,
119 f.line_buffering,
120 )
121
122 sys.stdin = _reopen_stdio(sys.stdin, "rb")
123 sys.stdout = _reopen_stdio(sys.stdout, "wb")

Callers 1

Calls 1

filenoMethod · 0.45

Tested by

no test coverage detected