From dac05ccd9a290ac232d933dfb2c4b0f651468867 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Wed, 29 Apr 2020 15:57:21 +0300 Subject: [PATCH] terminalwriter: remove support for passing callable as file in TerminalWriter Not used. --- src/_pytest/_io/terminalwriter.py | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/src/_pytest/_io/terminalwriter.py b/src/_pytest/_io/terminalwriter.py index c11eb9aba..437c96794 100644 --- a/src/_pytest/_io/terminalwriter.py +++ b/src/_pytest/_io/terminalwriter.py @@ -83,17 +83,14 @@ class TerminalWriter: ) # XXX deprecate stringio argument - def __init__(self, file=None, stringio=False, encoding=None): + def __init__(self, file=None, stringio=False): if file is None: if stringio: self.stringio = file = StringIO() else: from sys import stdout as file - elif callable(file) and not (hasattr(file, "write") and hasattr(file, "flush")): - file = WriteFile(file, encoding=encoding) if hasattr(file, "isatty") and file.isatty() and colorama: file = colorama.AnsiToWin32(file).stream - self.encoding = encoding or getattr(file, "encoding", "utf-8") self._file = file self.hasmarkup = should_do_markup(file) self._chars_on_current_line = 0 @@ -195,20 +192,6 @@ class TerminalWriter: self.write("\n") -class WriteFile: - def __init__(self, writemethod, encoding=None): - self.encoding = encoding - self._writemethod = writemethod - - def write(self, data): - if self.encoding: - data = data.encode(self.encoding, "replace") - self._writemethod(data) - - def flush(self): - return - - if win32_and_ctypes: import ctypes # noqa: F811 from ctypes import wintypes