File: conftest.py

package info (click to toggle)
mdformat 1.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 748 kB
  • sloc: python: 11,287; makefile: 9
file content (16 lines) | stat: -rw-r--r-- 322 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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