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

Function get_stderr_fileno

src/_pytest/faulthandler.py:62–75  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

60
61
62def get_stderr_fileno() -> int:
63 try:
64 fileno = sys.stderr.fileno()
65 # The Twisted Logger will return an invalid file descriptor since it is not backed
66 # by an FD. So, let's also forward this to the same code path as with pytest-xdist.
67 if fileno == -1:
68 raise AttributeError()
69 return fileno
70 except (AttributeError, ValueError):
71 # pytest-xdist monkeypatches sys.stderr with an object that is not an actual file.
72 # https://docs.python.org/3/library/faulthandler.html#issue-with-file-descriptors
73 # This is potentially dangerous, but the best we can do.
74 assert sys.__stderr__ is not None
75 return sys.__stderr__.fileno()
76
77
78def get_timeout_config_value(config: Config) -> float:

Callers 2

pytest_configureFunction · 0.85

Calls 1

filenoMethod · 0.45

Tested by 1