summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Sassoulas <pierre.sassoulas@gmail.com>2021-10-27 11:32:29 +0200
committerGitHub <noreply@github.com>2021-10-27 11:32:29 +0200
commitee85728805ca3bc9ab888b9224416aeb4861e0c3 (patch)
treee06249aa6bfc50de90498b07436ac325ba1bdb03
parent1f77ff6135bc280a6cfd46fc3bd917d3436d55e2 (diff)
downloadpylint-git-ee85728805ca3bc9ab888b9224416aeb4861e0c3.tar.gz
Fix deprecation 'check function will only accept sequence of string' (#5218)
* Fix deprecation 'check function will only accept sequence of string' * Add a test for Pylinter.check() deprecation
-rw-r--r--tests/lint/test_pylinter.py6
-rw-r--r--tests/test_regr.py32
2 files changed, 24 insertions, 14 deletions
diff --git a/tests/lint/test_pylinter.py b/tests/lint/test_pylinter.py
index 27fc10ebf..900d53fb3 100644
--- a/tests/lint/test_pylinter.py
+++ b/tests/lint/test_pylinter.py
@@ -35,3 +35,9 @@ def test_crash_in_file(
with open(files[0], encoding="utf8") as f:
content = f.read()
assert "Failed to import module spam." in content
+
+
+def test_check_deprecation(linter: PyLinter, recwarn):
+ linter.check("myfile.py")
+ msg = recwarn.pop()
+ assert "check function will only accept sequence" in str(msg)
diff --git a/tests/test_regr.py b/tests/test_regr.py
index 3e597d418..63b406b3d 100644
--- a/tests/test_regr.py
+++ b/tests/test_regr.py
@@ -26,7 +26,7 @@ import signal
import sys
from contextlib import contextmanager
from os.path import abspath, dirname, join
-from typing import Iterator
+from typing import Callable, Iterator, List
import astroid
import pytest
@@ -62,7 +62,7 @@ def Equals(expected):
@pytest.mark.parametrize(
- "file_name, check",
+ "file_names, check",
[
(["package.__init__"], Equals("")),
(["precedence_test"], Equals("")),
@@ -75,22 +75,24 @@ def Equals(expected):
([join(REGR_DATA, "bad_package")], lambda x: "Unused import missing" in x),
],
)
-def test_package(finalize_linter, file_name, check):
- finalize_linter.check(file_name)
+def test_package(
+ finalize_linter: PyLinter, file_names: List[str], check: Callable
+) -> None:
+ finalize_linter.check(file_names)
got = finalize_linter.reporter.finalize().strip()
assert check(got)
@pytest.mark.parametrize(
- "file_name",
+ "file_names",
[
- join(REGR_DATA, "import_assign.py"),
- join(REGR_DATA, "special_attr_scope_lookup_crash.py"),
- join(REGR_DATA, "try_finally_disable_msg_crash"),
+ [join(REGR_DATA, "import_assign.py")],
+ [join(REGR_DATA, "special_attr_scope_lookup_crash.py")],
+ [join(REGR_DATA, "try_finally_disable_msg_crash")],
],
)
-def test_crash(finalize_linter, file_name):
- finalize_linter.check(file_name)
+def test_crash(finalize_linter: PyLinter, file_names: List[str]) -> None:
+ finalize_linter.check(file_names)
@pytest.mark.parametrize(
@@ -156,11 +158,13 @@ def timeout(timeout_s: float):
@pytest.mark.skipif(not hasattr(signal, "setitimer"), reason="Assumes POSIX signals")
@pytest.mark.parametrize(
- "fname,timeout_s",
+ "file_names,timeout_s",
[
- (join(REGR_DATA, "hang", "pkg4972.string"), 30.0),
+ ([join(REGR_DATA, "hang", "pkg4972.string")], 30.0),
],
)
-def test_hang(finalize_linter, fname: str, timeout_s: float) -> None:
+def test_hang(
+ finalize_linter: PyLinter, file_names: List[str], timeout_s: float
+) -> None:
with timeout(timeout_s):
- finalize_linter.check(fname)
+ finalize_linter.check(file_names)