Example #1
0
def test_all_files():
    parser = PullRequestFilesParser()
    expected = 0
    for filename, count in FILE_EXPECTED:
        code = get_file_code(filename)
        parser.parse_code(filename, code)
        expected += count
    assert get_parser_total(parser) == expected
Example #2
0
def test_remove_all_labels():
    parser = PullRequestFilesParser()
    all_labels = [
        Label.REQUIRE_TEST, Label.DESCRIPTIVE_NAMES, Label.ANNOTATIONS
    ]
    add, remove = parser.labels_to_add_and_remove(all_labels)
    assert add == []
    assert remove == all_labels
Example #3
0
def test_skip_doctest():
    filename = "require_doctest.py"
    parser = PullRequestFilesParser()
    assert parser.skip_doctest is False
    parser.skip_doctest = True
    assert parser.skip_doctest is True
    code = get_file_code(filename)
    parser.parse_code(filename, code)
    assert get_parser_total(parser) == 0
Example #4
0
def test_add_all_labels():
    parser = PullRequestFilesParser()
    for filename, _ in FILE_EXPECTED:
        code = get_file_code(filename)
        parser.parse_code(filename, code)
    add, remove = parser.labels_to_add_and_remove([])
    assert add == [
        Label.REQUIRE_TEST, Label.DESCRIPTIVE_NAMES, Label.ANNOTATIONS
    ]
    assert remove == []
Example #5
0
def test_and_and_remove_labels():
    parser = PullRequestFilesParser()
    for i in range(1, 3):
        filename = FILE_EXPECTED[i][0]
        code = get_file_code(filename)
        parser.parse_code(filename, code)
    assert get_parser_total(parser) == 19
    add, remove = parser.labels_to_add_and_remove([Label.REQUIRE_TEST])
    assert add == [Label.DESCRIPTIVE_NAMES, Label.ANNOTATIONS]
    assert remove == [Label.REQUIRE_TEST]
Example #6
0
def test_node_path(cls_name, func_name, arg_name, expected):
    parser = PullRequestFilesParser()
    parser._filename = "test.py"
    assert (parser._node_path(cls_name=cls_name,
                              func_name=func_name,
                              arg_name=arg_name) == expected)
Example #7
0
def test_individual_files(filename, expected):
    code = get_file_code(filename)
    parser = PullRequestFilesParser()
    parser.parse_code(filename, code)
    attr = filename.split(".")[0]
    assert len(eval(f"parser._{attr}")) == expected