blob: 8200eec48c0e765da99c30b00525ca5558d544b3 [file] [edit]
import io
import sys
import pytest
@pytest.fixture
def patch_stdin(monkeypatch):
"""Fixture to patch sys.stdin for the running test."""
def set_stdin(text):
buffer = io.BytesIO(text.encode())
fobj = io.TextIOWrapper(buffer)
monkeypatch.setattr(sys, "stdin", fobj)
return set_stdin