Пример #1
0
    def test_pep263(self) -> None:
        p = StdPath("-").with_streams(
            stdin=io.BytesIO("# -*- coding: ascii -*-\nпривет".encode("utf-8")),
            stdout=io.BytesIO(),
        )

        assert p.is_file()

        with pytest.raises(UnicodeDecodeError):
            assert p.read_text()
Пример #2
0
    def test_stdin(self) -> None:
        p = StdPath("-").with_streams(
            stdin=io.BytesIO(b"  hello\n  world\n"), stdout=io.BytesIO()
        )

        assert p.is_file()

        assert p.read_text() == "hello\nworld\n"

        p.write_text("hello\nmars\n")
        p.stdout.seek(0)

        assert p.stdout.read() == b"  hello\n  mars\n"