fixup! typing: tests: tmpfile

This commit is contained in:
Daniel Hahler 2020-01-26 23:14:32 +01:00
parent d678d380cb
commit bf5c76359c
1 changed files with 7 additions and 7 deletions

View File

@ -10,7 +10,7 @@ import sys
from io import UnsupportedOperation from io import UnsupportedOperation
from tempfile import TemporaryFile from tempfile import TemporaryFile
from typing import BinaryIO from typing import BinaryIO
from typing import List from typing import Iterable
import pytest import pytest
from _pytest.compat import CaptureIO from _pytest.compat import CaptureIO
@ -419,15 +419,15 @@ class EncodedFile:
self.buffer = buffer self.buffer = buffer
self.encoding = encoding self.encoding = encoding
def write(self, obj: str) -> int: def write(self, s: str) -> int:
if not isinstance(obj, str): if not isinstance(s, str):
raise TypeError( raise TypeError(
"write() argument must be str, not {}".format(type(obj).__name__) "write() argument must be str, not {}".format(type(s).__name__)
) )
return self.buffer.write(obj.encode(self.encoding, "replace")) return self.buffer.write(s.encode(self.encoding, "replace"))
def writelines(self, linelist: List[str]) -> None: def writelines(self, lines: Iterable[str]) -> None:
self.buffer.writelines([x.encode(self.encoding, "replace") for x in linelist]) self.buffer.writelines(x.encode(self.encoding, "replace") for x in lines)
@property @property
def name(self) -> str: def name(self) -> str: