Esempio n. 1
0
    def test_file(self) -> None:
        p = StdPath("test").with_streams(
            filein=OpenBytesIO(b"hello world"), fileout=OpenBytesIO()
        )

        assert p.read_text() == "hello world"

        p.write_text("hello mars")

        assert p.fileout.read() == b"hello mars"
Esempio n. 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"