Ejemplo n.º 1
0
def test_main_head_request(capsys):
    args = ["--head", "4", ROBOTO_BEFORE_PATH, ROBOTO_AFTER_PATH]

    run(args)
    captured = capsys.readouterr()
    res_string_list = captured.out.split("\n")

    # includes a newline at the end of the last line of output
    # which makes the total # of lines in the list == n + 1
    assert len(res_string_list) == 5

    # have to handle the tests for the top two file path lines
    # differently than the rest of the comparisons because
    # the time is defined using local platform settings
    # which makes tests fail on different remote CI testing services
    for x, line in enumerate(res_string_list):
        # treat top two lines of the diff as comparison of first 10 chars only
        if x == 0:
            assert line.startswith("---")
        elif x == 1:
            assert line.startswith("+++")
        elif x == 2:
            assert line == "@@ -4,34 +4,34 @@"
        elif x == 3:
            assert line == "   <GlyphOrder>"
        else:
            assert line == ""
Ejemplo n.º 2
0
def test_main_run_unified_default_local_files_no_diff(capsys):
    """Test default behavior when there is no difference in font files under evaluation"""
    args = [ROBOTO_BEFORE_PATH, ROBOTO_BEFORE_PATH]

    run(args)
    captured = capsys.readouterr()
    assert captured.out.startswith(
        "[*] There is no difference between the files.")
Ejemplo n.º 3
0
def test_main_run_unified_default_404(capsys):
    with pytest.raises(SystemExit):
        args = [URL_404, URL_404]

        run(args)
        captured = capsys.readouterr()
        assert captured.out.startswith("[*] ERROR:")
        assert "HTTP status code 404" in captured.out
Ejemplo n.º 4
0
def test_main_exclude_with_bad_table_definition_in_multi_table_request(capsys):
    args = ["--exclude", "head,bogus", ROBOTO_BEFORE_PATH, ROBOTO_AFTER_PATH]

    with pytest.raises(SystemExit) as exit_info:
        run(args)

    captured = capsys.readouterr()
    assert captured.err.startswith("[*] ERROR:")
    assert exit_info.value.code == 1
Ejemplo n.º 5
0
def test_main_external_diff_with_tail_fails(capsys):
    args = ["--external", "diff -u", "--tail", "1", ROBOTO_BEFORE_PATH, ROBOTO_AFTER_PATH]

    with pytest.raises(SystemExit) as exit_info:
        run(args)

    captured = capsys.readouterr()
    assert "[ERROR] The head and tail options are not supported" in captured.err
    assert exit_info.value.code == 1
Ejemplo n.º 6
0
def test_main_filepath_validations_false_secondfont(capsys):
    test_path_2 = os.path.join("tests", "testfiles", "bogus-font.ttf")
    args = [ROBOTO_BEFORE_PATH, test_path_2]

    with pytest.raises(SystemExit) as exit_info:
        run(args)

    captured = capsys.readouterr()
    assert captured.err.startswith("[*] ERROR: The file path")
    assert exit_info.value.code == 1
Ejemplo n.º 7
0
def test_main_include_exclude_defined_simultaneously(capsys):
    args = [
        "--include", "head", "--exclude", "head", ROBOTO_BEFORE_PATH,
        ROBOTO_AFTER_PATH
    ]

    with pytest.raises(SystemExit) as exit_info:
        run(args)

    captured = capsys.readouterr()
    assert captured.err.startswith(
        "[*] Error: --include and --exclude are mutually exclusive options")
    assert exit_info.value.code == 1
Ejemplo n.º 8
0
def test_main_external_diff_remote(capsys):
    args = ["--external", "diff -u", ROBOTO_BEFORE_URL, ROBOTO_AFTER_URL]
    expected_string_list = ROBOTO_EXTDIFF_EXPECTED.split("\n")

    with pytest.raises(SystemExit):
        run(args)

    captured = capsys.readouterr()
    res_string_list = captured.out.split("\n")
    for x, line in enumerate(res_string_list):
        # treat top two lines of the diff as comparison of first 3 chars only
        if x in (0, 1):
            assert line[0:2] == expected_string_list[x][0:2]
        elif x in range(2, 10):
            assert line == expected_string_list[x]
        else:
            # skip lines beyond first 10
            pass
Ejemplo n.º 9
0
def test_main_run_unified_exclude_head_post_tables(capsys):
    args = ["--exclude", "head,post", ROBOTO_BEFORE_PATH, ROBOTO_AFTER_PATH]

    run(args)
    captured = capsys.readouterr()

    res_string_list = captured.out.split("\n")
    expected_string_list = ROBOTO_UDIFF_EXCLUDE_HEADPOST_EXPECTED.split("\n")

    # have to handle the tests for the top two file path lines
    # differently than the rest of the comparisons because
    # the time is defined using local platform settings
    # which makes tests fail on different remote CI testing services
    for x, line in enumerate(res_string_list):
        # treat top two lines of the diff as comparison of first 10 chars only
        if x in (0, 1):
            assert line[0:9] == expected_string_list[x][0:9]
        else:
            assert line == expected_string_list[x]
Ejemplo n.º 10
0
def test_main_run_unified_color(capsys):
    # prior to v3.0.0, the `-c` / `--color` option was required for color output
    # this is the default as of v3.0.0 and the test arguments were
    # modified here
    args = [ROBOTO_BEFORE_PATH, ROBOTO_AFTER_PATH]
    # we also need to mock sys.stdout.isatty because color does not
    # show when this returns False
    sys.stdout.isatty = MagicMock(return_value=True)

    run(args)
    captured = capsys.readouterr()
    # spot checks for escape code start sequence
    res_string_list = captured.out.split("\n")
    assert captured.out.startswith("\x1b")
    assert res_string_list[10].startswith("\x1b")
    assert res_string_list[71].startswith("\x1b")
    assert res_string_list[180].startswith("\x1b")
    assert res_string_list[200].startswith("\x1b")
    assert res_string_list[238].startswith("\x1b")
Ejemplo n.º 11
0
def test_main_run_unified_default_remote_files(capsys):
    args = [ROBOTO_BEFORE_URL, ROBOTO_AFTER_URL]

    run(args)
    captured = capsys.readouterr()

    res_string_list = captured.out.split("\n")
    expected_string_list = ROBOTO_UDIFF_EXPECTED.split("\n")

    # have to handle the tests for the top two file path lines
    # differently than the rest of the comparisons because
    # the time is defined using local platform settings
    # which makes tests fail on different remote CI testing services
    for x, line in enumerate(res_string_list):
        # treat top two lines of the diff as comparison of first 10 chars only
        if x == 0:
            assert line[0:9] == "--- https"
        elif x == 1:
            assert line[0:9] == "+++ https"
        else:
            assert line == expected_string_list[x]
Ejemplo n.º 12
0
def test_main_external_diff_color(capsys):
    # prior to v3.0.0, the `-c` / `--color` option was required for color output
    # this is the default as of v3.0.0 and the test arguments were
    # modified here
    args = ["--external", "diff -u", ROBOTO_BEFORE_PATH, ROBOTO_AFTER_PATH]
    # we also need to patch sys.stdout.isatty because color does not
    # show when this returns False
    sys.stdout.isatty = MagicMock(return_value=True)
    # expected_string_list = ROBOTO_EXTDIFF_COLOR_EXPECTED.split("\n")

    with pytest.raises(SystemExit):
        run(args)

    captured = capsys.readouterr()

    # spot checks for escape code start sequence
    res_string_list = captured.out.split("\n")
    assert captured.out.startswith("\x1b")
    assert res_string_list[10].startswith("\x1b")
    assert res_string_list[71].startswith("\x1b")
    assert res_string_list[180].startswith("\x1b")
    assert res_string_list[200].startswith("\x1b")
    assert res_string_list[238].startswith("\x1b")