summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndreas Motl <andreas@getkotori.org>2021-01-17 19:23:57 +0100
committerAndreas Motl <andreas@getkotori.org>2021-01-18 17:51:08 +0100
commit9ba1821e9121c3ee49a68b4863cd7ee50de4a5a5 (patch)
tree1c8fb38106c5271d1427e8073905ea551d10a53a /src
parentc9e9a599fe5231da90967b6f77c73e17c12740b7 (diff)
downloadpytest-9ba1821e9121c3ee49a68b4863cd7ee50de4a5a5.tar.gz
Fix faulthandler for Twisted Logger when used with "--capture=no"
The Twisted Logger will return an invalid file descriptor since it is not backed by an FD. So, let's also forward this to the same code path as with `pytest-xdist`.
Diffstat (limited to 'src')
-rw-r--r--src/_pytest/faulthandler.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/_pytest/faulthandler.py b/src/_pytest/faulthandler.py
index d0cc0430c..ff673b5b1 100644
--- a/src/_pytest/faulthandler.py
+++ b/src/_pytest/faulthandler.py
@@ -69,7 +69,12 @@ class FaultHandlerHooks:
@staticmethod
def _get_stderr_fileno():
try:
- return sys.stderr.fileno()
+ fileno = sys.stderr.fileno()
+ # The Twisted Logger will return an invalid file descriptor since it is not backed
+ # by an FD. So, let's also forward this to the same code path as with pytest-xdist.
+ if fileno == -1:
+ raise AttributeError()
+ return fileno
except (AttributeError, io.UnsupportedOperation):
# pytest-xdist monkeypatches sys.stderr with an object that is not an actual file.
# https://docs.python.org/3/library/faulthandler.html#issue-with-file-descriptors