pyodide/packages/pytest/patches/use-named-temporary-file.patch

58 lines
2.1 KiB
Diff
Raw Normal View History

2018-08-23 10:08:51 +00:00
diff --git a/src/_pytest/capture.py b/src/_pytest/capture.py
2018-08-23 14:48:57 +00:00
index faa767a8..551484b0 100644
2018-08-23 10:08:51 +00:00
--- a/src/_pytest/capture.py
+++ b/src/_pytest/capture.py
@@ -10,7 +10,7 @@ import sys
import os
import io
from io import UnsupportedOperation
-from tempfile import TemporaryFile
+from tempfile import NamedTemporaryFile as TemporaryFile
import six
import pytest
2018-08-23 14:48:57 +00:00
@@ -482,7 +482,7 @@ class FDCaptureBinary(object):
os.fstat(self.targetfd_save)
except (AttributeError, OSError):
raise ValueError("saved filedescriptor not valid anymore")
- os.dup2(self.tmpfile_fd, self.targetfd)
+ self.tmpfile_fd = os.dup(self.targetfd)
self.syscapture.start()
def snap(self):
@@ -496,18 +496,18 @@ class FDCaptureBinary(object):
""" stop capturing, restore streams, return original capture file,
seeked to position zero. """
targetfd_save = self.__dict__.pop("targetfd_save")
- os.dup2(targetfd_save, self.targetfd)
+ targetfd_save = os.dup(self.targetfd)
os.close(targetfd_save)
self.syscapture.done()
_attempt_to_close_capture_file(self.tmpfile)
def suspend(self):
self.syscapture.suspend()
- os.dup2(self.targetfd_save, self.targetfd)
+ self.targetfd_save = os.dup(self.targetfd)
def resume(self):
self.syscapture.resume()
- os.dup2(self.tmpfile_fd, self.targetfd)
+ self.tmpfile_fd = os.dup(self.targetfd)
def writeorg(self, data):
""" write to original file descriptor. """
2018-08-23 10:08:51 +00:00
diff --git a/src/_pytest/pastebin.py b/src/_pytest/pastebin.py
index 6af202d1..9b192918 100644
--- a/src/_pytest/pastebin.py
+++ b/src/_pytest/pastebin.py
@@ -29,7 +29,7 @@ def pytest_configure(config):
# when using pytest-xdist, for example
if tr is not None:
# pastebin file will be utf-8 encoded binary file
- config._pastebinfile = tempfile.TemporaryFile("w+b")
+ config._pastebinfile = tempfile.NamedTemporaryFile("w+b")
oldwrite = tr._tw.write
def tee_write(s, **kwargs):