add comment about why we're stashing stderr fileno

This commit is contained in:
Simon Blanchard 2023-11-05 13:42:49 +01:00
parent e340a075e5
commit 6bd3d8404d
1 changed files with 3 additions and 0 deletions

View File

@ -25,6 +25,9 @@ def pytest_addoption(parser: Parser) -> None:
def pytest_configure(config: Config) -> None:
import faulthandler
# stash original stderr fileno to be restored at the end of the test session
# sys.stderr and sys.__stderr__ may be closed or patched during the session
# so we can't rely on their values being good at that point
stderr_fileno = get_stderr_fileno()
config.stash[fault_handler_original_stderr_fd_key] = stderr_fileno
config.stash[fault_handler_stderr_fd_key] = os.dup(stderr_fileno)