diff options
author | Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com> | 2021-11-25 10:09:43 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-25 10:09:43 +0100 |
commit | fa7a84fa712915fde725cda63a5bfbf4ed5cd22a (patch) | |
tree | bc66347c7b6be4b3bc25bb07e74133b9defb772e /tests/testutils | |
parent | be149db10f756301a6f18c245fa799d7beec6648 (diff) | |
download | pylint-git-fa7a84fa712915fde725cda63a5bfbf4ed5cd22a.tar.gz |
Add ``min_pyver_end_position`` option (#5386)
* Add ``min_pyver_end_position`` option
Diffstat (limited to 'tests/testutils')
-rw-r--r-- | tests/testutils/test_output_line.py | 83 |
1 files changed, 68 insertions, 15 deletions
diff --git a/tests/testutils/test_output_line.py b/tests/testutils/test_output_line.py index 25f784a54..eafb3eb53 100644 --- a/tests/testutils/test_output_line.py +++ b/tests/testutils/test_output_line.py @@ -55,35 +55,66 @@ def test_output_line() -> None: 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 - expected_end_lineno = 1 if PY38_PLUS else None - expected_end_column = 3 if PY38_PLUS else None + 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 == expected_end_lineno - assert output_line.end_column == expected_end_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" + @pytest.mark.parametrize("confidence", [HIGH, INFERENCE]) 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)) + output_line = OutputLine.from_msg(message(confidence), True) csv = output_line.to_csv() expected_column = "2" if PY38_PLUS else "0" - expected_end_lineno = "1" if PY38_PLUS else "None" - expected_end_column = "3" if PY38_PLUS else "None" assert csv == ( "missing-docstring", "1", expected_column, - expected_end_lineno, - expected_end_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, @@ -96,12 +127,12 @@ def test_output_line_from_csv_error() -> None: MalformedOutputLineException, match="msg-symbolic-name:42:27:MyClass.my_function:The message", ): - OutputLine.from_csv("'missing-docstring', 'line', 'column', 'obj', 'msg'") + OutputLine.from_csv("'missing-docstring', 'line', 'column', 'obj', 'msg'", True) with pytest.raises( MalformedOutputLineException, match="symbol='missing-docstring' ?" ): csv = ("missing-docstring", "line", "column", "obj", "msg") - OutputLine.from_csv(csv) + OutputLine.from_csv(csv, True) @pytest.mark.parametrize( @@ -125,7 +156,7 @@ def test_output_line_from_csv_deprecated( else: proper_csv = ["missing-docstring", "1", "2", "obj", "msg"] with pytest.warns(DeprecationWarning) as records: - output_line = OutputLine.from_csv(proper_csv) + output_line = OutputLine.from_csv(proper_csv, True) assert len(records) == 1 expected_column = 2 if PY38_PLUS else 0 @@ -155,14 +186,36 @@ def test_output_line_from_csv() -> None: "msg", "HIGH", ] - output_line = OutputLine.from_csv(proper_csv) expected_column = 2 if PY38_PLUS else 0 - expected_end_lineno = 1 if PY38_PLUS else None + + output_line = OutputLine.from_csv(proper_csv) assert output_line == OutputLine( symbol="missing-docstring", lineno=1, column=expected_column, - end_lineno=expected_end_lineno, + end_lineno=1, + end_column=None, + object="obj", + msg="msg", + confidence="HIGH", + ) + output_line_with_end = OutputLine.from_csv(proper_csv, True) + assert output_line_with_end == OutputLine( + symbol="missing-docstring", + lineno=1, + column=expected_column, + end_lineno=1, + end_column=None, + object="obj", + msg="msg", + confidence="HIGH", + ) + output_line_without_end = OutputLine.from_csv(proper_csv, False) + assert output_line_without_end == OutputLine( + symbol="missing-docstring", + lineno=1, + column=expected_column, + end_lineno=None, end_column=None, object="obj", msg="msg", |