コード例 #1
0
def test_main_stdin_diff(capsys):
    with mock_stdin(" a()"):
        main(["-d"])
    captured = capsys.readouterr()
    assert "- a()" in captured.out
    assert "+a()" in captured.out
    assert captured.err == ""
コード例 #2
0
def test_main_file_1(capsys, tmp_path):
    testfile1 = tmp_path / "list1.cmake"
    with testfile1.open("w") as fp:
        fp.write(" a()")

    main([str(testfile1)])
    captured = capsys.readouterr()
    assert captured.out == "a()\n"
    assert captured.err == ""
コード例 #3
0
def test_main_diff(capsys, tmp_path):
    testfile1 = tmp_path / "list1.cmake"
    with testfile1.open("w") as fp:
        fp.write(" a()")

    main(["-d", str(testfile1)])
    captured = capsys.readouterr()
    assert str(testfile1) in captured.out
    assert "- a()" in captured.out
    assert "+a()" in captured.out
    assert captured.err == ""
コード例 #4
0
def test_main_file_2(capsys: CaptureFixture[str], tmp_path: Path) -> None:
    testfile1 = tmp_path / "list1.cmake"
    with testfile1.open("w") as fp:
        fp.write(" a()")
    testfile2 = tmp_path / "list2.cmake"
    with testfile2.open("w") as fp:
        fp.write(" b()")

    main([str(testfile1), str(testfile2)])
    captured = capsys.readouterr()
    assert captured.out == "a()\nb()\n"
    assert captured.err == ""
コード例 #5
0
def test_main_inplace(capsys, tmp_path):
    testfile1 = tmp_path / "list1.cmake"
    with testfile1.open("w") as fp:
        fp.write(" a()")

    main(["-i", str(testfile1)])
    captured = capsys.readouterr()
    assert captured.out == ""
    assert captured.err == ""

    with testfile1.open() as fp:
        content = fp.read()
    assert content == "a()\n"
コード例 #6
0
def test_main_stdin(capsys):
    with mock_stdin(" a()"):
        main([])
    captured = capsys.readouterr()
    assert captured.out == "a()\n"
    assert captured.err == ""
コード例 #7
0
def test_main_stdin(capsys: CaptureFixture[str]) -> None:
    with mock_stdin(" a()"):
        main([])
    captured = capsys.readouterr()
    assert captured.out == "a()\n"
    assert captured.err == ""