Add return type _string_to_tmp_file helper

This commit is contained in:
Daniël de Kok 2023-01-19 11:35:59 +01:00
parent 5e84e5b41c
commit 8c27fcfd1b

View File

@ -1,4 +1,4 @@
from typing import Iterable, List, Tuple from typing import IO, Generator, Iterable, List, TextIO, Tuple
from contextlib import contextmanager from contextlib import contextmanager
from pathlib import Path from pathlib import Path
import pytest import pytest
@ -55,7 +55,7 @@ def test_plain_text_reader(min_length, max_length):
@contextmanager @contextmanager
def _string_to_tmp_file(s: str): def _string_to_tmp_file(s: str) -> Generator[IO, None, None]:
with tempfile.NamedTemporaryFile(suffix=".txt") as f: with tempfile.NamedTemporaryFile(suffix=".txt") as f:
f.write(s.encode("utf-8")) f.write(s.encode("utf-8"))
f.seek(0) f.seek(0)