Skip to content

Commit e4fd275

Browse files
committed
Add additional tests for OutputLine
1 parent 16a4e30 commit e4fd275

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/testutils/test_output_line.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def inner(confidence: Confidence = HIGH) -> Message:
3636

3737

3838
def test_output_line() -> None:
39+
"""Test that the OutputLine NamedTuple is instantiated correctly."""
3940
output_line = OutputLine(
4041
symbol="missing-docstring",
4142
lineno=1,
@@ -45,16 +46,30 @@ def test_output_line() -> None:
4546
confidence=HIGH.name,
4647
)
4748
assert output_line.symbol == "missing-docstring"
49+
assert output_line.lineno == 1
50+
assert output_line.column == 2
51+
assert output_line.object == ""
52+
assert output_line.msg == "Missing docstring's bad."
53+
assert output_line.confidence == "HIGH"
4854

4955

5056
def test_output_line_from_message(message: Callable) -> None:
57+
"""Test that the OutputLine NamedTuple is instantiated correctly with from_msg."""
58+
expected_column = 2 if PY38_PLUS else 0
5159
output_line = OutputLine.from_msg(message())
5260
assert output_line.symbol == "missing-docstring"
61+
assert output_line.lineno == 1
62+
assert output_line.column == expected_column
63+
assert output_line.object == "obj"
5364
assert output_line.msg == "msg"
65+
assert output_line.confidence == "HIGH"
5466

5567

5668
@pytest.mark.parametrize("confidence", [HIGH, INFERENCE])
5769
def test_output_line_to_csv(confidence: Confidence, message: Callable) -> None:
70+
"""Test that the OutputLine NamedTuple is instantiated correctly with from_msg
71+
and then converted to csv.
72+
"""
5873
output_line = OutputLine.from_msg(message(confidence))
5974
csv = output_line.to_csv()
6075
expected_column = "2" if PY38_PLUS else "0"
@@ -69,6 +84,7 @@ def test_output_line_to_csv(confidence: Confidence, message: Callable) -> None:
6984

7085

7186
def test_output_line_from_csv_error() -> None:
87+
"""Test that errors are correctly raised for incorrect OutputLine's."""
7288
with pytest.raises(
7389
MalformedOutputLineException,
7490
match="msg-symbolic-name:42:27:MyClass.my_function:The message",
@@ -87,6 +103,7 @@ def test_output_line_from_csv_error() -> None:
87103
def test_output_line_from_csv(
88104
confidence: Optional[str], expected_confidence: str
89105
) -> None:
106+
"""Test that the OutputLine NamedTuple is instantiated correctly with from_csv."""
90107
if confidence:
91108
proper_csv = [
92109
"missing-docstring",

0 commit comments

Comments
 (0)