def test_get_groups(): with open(os.path.join(test_data_directory, "pylint_output.txt")) as f: groups = group_errors(parse(f)) # Sort the groups so we can do the assertions below groups = sorted(groups, key=lambda x: (x.offending_object, x.error_category)) assert len(list(groups)) == 5 assert groups[0].error_category == "C" assert groups[0].offending_object == "AttributeNode" assert groups[0].offending_method == "" assert groups[1].error_category == "C" assert groups[1].offending_object == "AttributeNode" assert groups[1].offending_method == "parse" assert groups[2].error_category == "W" assert groups[2].offending_object == "AttributeNode" assert groups[2].offending_method == "parse" assert groups[3].error_category == "C" assert groups[3].offending_object == "DefineNode" assert groups[3].offending_method == "parse" assert groups[4].error_category == "W" assert groups[4].offending_object == "DefineNode" assert groups[4].offending_method == "parse"
def test_parse_complete(): """Parse a full pylint output which includes lines that aren't actually pylint data, but just visual separators or something.""" with open(os.path.join(test_data_directory, "pylint_output_complete.txt")) as f: df = parse(f) assert len(df) == 84
def test_group_errors_complete(): """Parse a complete pylint output, exactly as you'd get if you ran pylint on the command line, and group the errors. This is just a smoke test to make sure nothing crashes.""" with open(os.path.join(test_data_directory, "pylint_output_complete.txt")) as f: # Loop because group_errors might be a generator for _ in group_errors(parse(f)): pass
def test_parse(): with open(os.path.join(test_data_directory, "pylint_output.txt")) as f: df = parse(f) assert len(df) == 10
def test_organize_animals(): """Another massive smoke test""" with open(os.path.join(test_data_directory, "pylint_output_complete.txt")) as f: organize_animals(create_animals(group_errors(parse(f))))
def test_create_animals(): """Same as test_group_errors_complete except create the corresponding animals too.""" with open(os.path.join(test_data_directory, "pylint_output.txt")) as f: # Should have 5 animals because the end result had 5 LintErrorGroups assert len(create_animals(group_errors(parse(f)))) == 5