File: test_stdio.py

package info (click to toggle)
aiofiles 25.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 324 kB
  • sloc: python: 1,791; makefile: 3; sh: 1
file content (23 lines) | stat: -rw-r--r-- 625 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import pytest

from aiofiles import stderr, stderr_bytes, stdin, stdin_bytes, stdout, stdout_bytes


async def test_stdio(capsys):
    await stdout.write("hello")
    await stderr.write("world")
    out, err = capsys.readouterr()
    assert out == "hello"
    assert err == "world"
    with pytest.raises(OSError):
        await stdin.read()


async def test_stdio_bytes(capsysbinary):
    await stdout_bytes.write(b"hello")
    await stderr_bytes.write(b"world")
    out, err = capsysbinary.readouterr()
    assert out == b"hello"
    assert err == b"world"
    with pytest.raises(OSError):
        await stdin_bytes.read()