Beispiel #1
0
def test_output_line_to_csv(confidence: Confidence, message: Callable) -> None:
    """Test that the OutputLine NamedTuple is instantiated correctly with from_msg
    and then converted to csv.
    """
    output_line = OutputLine.from_msg(message(confidence), True)
    csv = output_line.to_csv()
    expected_column = "2" if PY38_PLUS else "0"
    assert csv == (
        "missing-docstring",
        "1",
        expected_column,
        "1",
        "3",
        "obj",
        "msg",
        confidence.name,
    )

    output_line_without_end = OutputLine.from_msg(message(confidence), False)
    csv = output_line_without_end.to_csv()
    expected_column = "2" if PY38_PLUS else "0"
    assert csv == (
        "missing-docstring",
        "1",
        expected_column,
        "None",
        "None",
        "obj",
        "msg",
        confidence.name,
    )
Beispiel #2
0
def test_output_line_from_message(message: Callable) -> None:
    """Test that the OutputLine NamedTuple is instantiated correctly with from_msg."""
    expected_column = 2 if PY38_PLUS else 0

    output_line = OutputLine.from_msg(message())
    assert output_line.symbol == "missing-docstring"
    assert output_line.lineno == 1
    assert output_line.column == expected_column
    assert output_line.end_lineno == 1
    assert output_line.end_column == 3
    assert output_line.object == "obj"
    assert output_line.msg == "msg"
    assert output_line.confidence == "HIGH"

    output_line_with_end = OutputLine.from_msg(message(), True)
    assert output_line_with_end.symbol == "missing-docstring"
    assert output_line_with_end.lineno == 1
    assert output_line_with_end.column == expected_column
    assert output_line_with_end.end_lineno == 1
    assert output_line_with_end.end_column == 3
    assert output_line_with_end.object == "obj"
    assert output_line_with_end.msg == "msg"
    assert output_line_with_end.confidence == "HIGH"

    output_line_without_end = OutputLine.from_msg(message(), False)
    assert output_line_without_end.symbol == "missing-docstring"
    assert output_line_without_end.lineno == 1
    assert output_line_without_end.column == expected_column
    assert output_line_without_end.end_lineno is None
    assert output_line_without_end.end_column is None
    assert output_line_without_end.object == "obj"
    assert output_line_without_end.msg == "msg"
    assert output_line_without_end.confidence == "HIGH"
Beispiel #3
0
 def _get_actual(self):
     messages = self._linter.reporter.messages
     messages.sort(key=lambda m: (m.line, m.symbol, m.msg))
     received_msgs = Counter()
     received_output_lines = []
     for msg in messages:
         assert (msg.symbol !=
                 "fatal"), f"Pylint analysis failed because of '{msg.msg}'"
         received_msgs[msg.line, msg.symbol] += 1
         received_output_lines.append(OutputLine.from_msg(msg))
     return received_msgs, received_output_lines
Beispiel #4
0
 def _get_actual(self) -> Tuple[MessageCounter, List[OutputLine]]:
     messages: List[Message] = self._linter.reporter.messages
     messages.sort(key=lambda m: (m.line, m.symbol, m.msg))
     received_msgs: MessageCounter = Counter()
     received_output_lines = []
     for msg in messages:
         assert (msg.symbol !=
                 "fatal"), f"Pylint analysis failed because of '{msg.msg}'"
         received_msgs[msg.line, msg.symbol] += 1
         received_output_lines.append(
             OutputLine.from_msg(msg, self._check_end_position))
     return received_msgs, received_output_lines
Beispiel #5
0
def test_output_line_to_csv(confidence: Confidence, message: Callable) -> None:
    output_line = OutputLine.from_msg(message(confidence))
    csv = output_line.to_csv()
    expected_column = "2" if PY38_PLUS else "0"
    assert csv == (
        "missing-docstring",
        "1",
        expected_column,
        "obj",
        "msg",
        confidence.name,
    )
Beispiel #6
0
def test_output_line_from_message(message: Callable) -> None:
    output_line = OutputLine.from_msg(message())
    assert output_line.symbol == "missing-docstring"
    assert output_line.msg == "msg"