diff options
author | Daniël van Noord <13665637+DanielNoord@users.noreply.github.com> | 2021-11-22 20:09:02 +0100 |
---|---|---|
committer | Daniël van Noord <13665637+DanielNoord@users.noreply.github.com> | 2021-11-22 20:19:22 +0100 |
commit | e4fd27544c04c9637b89fb678c1df19166506a10 (patch) | |
tree | 7e7b58b9f0ba88d72acec063bae925b302967dd8 | |
parent | 16a4e30da9ed738161372c5d12b5fd8f100d0f78 (diff) | |
download | pylint-git-e4fd27544c04c9637b89fb678c1df19166506a10.tar.gz |
Add additional tests for ``OutputLine``
-rw-r--r-- | tests/testutils/test_output_line.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/testutils/test_output_line.py b/tests/testutils/test_output_line.py index 46135dd20..d13db4978 100644 --- a/tests/testutils/test_output_line.py +++ b/tests/testutils/test_output_line.py @@ -36,6 +36,7 @@ def message() -> Callable: def test_output_line() -> None: + """Test that the OutputLine NamedTuple is instantiated correctly.""" output_line = OutputLine( symbol="missing-docstring", lineno=1, @@ -45,16 +46,30 @@ def test_output_line() -> None: confidence=HIGH.name, ) assert output_line.symbol == "missing-docstring" + assert output_line.lineno == 1 + assert output_line.column == 2 + assert output_line.object == "" + assert output_line.msg == "Missing docstring's bad." + assert output_line.confidence == "HIGH" 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.object == "obj" assert output_line.msg == "msg" + assert output_line.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)) csv = output_line.to_csv() expected_column = "2" if PY38_PLUS else "0" @@ -69,6 +84,7 @@ def test_output_line_to_csv(confidence: Confidence, message: Callable) -> None: def test_output_line_from_csv_error() -> None: + """Test that errors are correctly raised for incorrect OutputLine's.""" with pytest.raises( MalformedOutputLineException, match="msg-symbolic-name:42:27:MyClass.my_function:The message", @@ -87,6 +103,7 @@ def test_output_line_from_csv_error() -> None: def test_output_line_from_csv( confidence: Optional[str], expected_confidence: str ) -> None: + """Test that the OutputLine NamedTuple is instantiated correctly with from_csv.""" if confidence: proper_csv = [ "missing-docstring", |