summaryrefslogtreecommitdiff
path: root/tests/reporters
diff options
context:
space:
mode:
authorDaniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>2022-09-09 15:06:13 +0200
committerGitHub <noreply@github.com>2022-09-09 15:06:13 +0200
commit6524ba540cbfc4f11e924925faebe7e21f87942e (patch)
tree651c092d18df42eb18d0c066e5af8b996e0c46c7 /tests/reporters
parent2b6bd64d43ed109b1ee15f0993c010660cf56b13 (diff)
downloadpylint-git-6524ba540cbfc4f11e924925faebe7e21f87942e.tar.gz
Finish unfinished typing in non core directories (#7443)
* Add typing to setup calls in documentation folder * Finish some incomplete typing signatures in script * Add typing to unfinished signatures in the tests directory
Diffstat (limited to 'tests/reporters')
-rw-r--r--tests/reporters/unittest_json_reporter.py2
-rw-r--r--tests/reporters/unittest_reporting.py26
2 files changed, 16 insertions, 12 deletions
diff --git a/tests/reporters/unittest_json_reporter.py b/tests/reporters/unittest_json_reporter.py
index 90a67fceb..a4a3d65d3 100644
--- a/tests/reporters/unittest_json_reporter.py
+++ b/tests/reporters/unittest_json_reporter.py
@@ -131,7 +131,7 @@ def get_linter_result(score: bool, message: dict[str, Any]) -> list[dict[str, An
)
],
)
-def test_serialize_deserialize(message):
+def test_serialize_deserialize(message: Message) -> None:
# TODO: 3.0: Add confidence handling, add path and abs path handling or a new JSONReporter
json_message = JSONReporter.serialize(message)
assert message == JSONReporter.deserialize(json_message)
diff --git a/tests/reporters/unittest_reporting.py b/tests/reporters/unittest_reporting.py
index ea7d6758b..f08546679 100644
--- a/tests/reporters/unittest_reporting.py
+++ b/tests/reporters/unittest_reporting.py
@@ -11,9 +11,11 @@ import warnings
from contextlib import redirect_stdout
from io import StringIO
from json import dumps
-from typing import TYPE_CHECKING
+from pathlib import Path
+from typing import TYPE_CHECKING, TextIO
import pytest
+from _pytest.recwarn import WarningsRecorder
from pylint import checkers
from pylint.lint import PyLinter
@@ -26,12 +28,12 @@ if TYPE_CHECKING:
@pytest.fixture(scope="module")
-def reporter():
+def reporter() -> type[TextReporter]:
return TextReporter
@pytest.fixture(scope="module")
-def disable():
+def disable() -> list[str]:
return ["I"]
@@ -111,7 +113,7 @@ def test_template_option_non_existing(linter: PyLinter) -> None:
assert out_lines[2] == "my_mod:2::()"
-def test_deprecation_set_output(recwarn):
+def test_deprecation_set_output(recwarn: WarningsRecorder) -> None:
"""TODO remove in 3.0."""
reporter = BaseReporter()
# noinspection PyDeprecation
@@ -121,7 +123,7 @@ def test_deprecation_set_output(recwarn):
assert reporter.out == sys.stdout
-def test_parseable_output_deprecated():
+def test_parseable_output_deprecated() -> None:
with warnings.catch_warnings(record=True) as cm:
warnings.simplefilter("always")
ParseableTextReporter()
@@ -130,7 +132,7 @@ def test_parseable_output_deprecated():
assert isinstance(cm[0].message, DeprecationWarning)
-def test_parseable_output_regression():
+def test_parseable_output_regression() -> None:
output = StringIO()
with warnings.catch_warnings(record=True):
linter = PyLinter(reporter=ParseableTextReporter())
@@ -153,18 +155,18 @@ class NopReporter(BaseReporter):
name = "nop-reporter"
extension = ""
- def __init__(self, output=None):
+ def __init__(self, output: TextIO | None = None) -> None:
super().__init__(output)
print("A NopReporter was initialized.", file=self.out)
- def writeln(self, string=""):
+ def writeln(self, string: str = "") -> None:
pass
def _display(self, layout: Section) -> None:
pass
-def test_multi_format_output(tmp_path):
+def test_multi_format_output(tmp_path: Path) -> None:
text = StringIO(newline=None)
json = tmp_path / "somefile.json"
@@ -189,7 +191,9 @@ def test_multi_format_output(tmp_path):
linter.reporter.out = text
linter.open()
- linter.check_single_file_item(FileItem("somemodule", source_file, "somemodule"))
+ linter.check_single_file_item(
+ FileItem("somemodule", str(source_file), "somemodule")
+ )
linter.add_message("line-too-long", line=1, args=(1, 2))
linter.generate_reports()
linter.reporter.writeln("direct output")
@@ -330,7 +334,7 @@ def test_multi_format_output(tmp_path):
)
-def test_display_results_is_renamed():
+def test_display_results_is_renamed() -> None:
class CustomReporter(TextReporter):
def _display(self, layout: Section) -> None:
return None