summaryrefslogtreecommitdiff
path: root/tests/test_self.py
diff options
context:
space:
mode:
authorChristoph Blessing <33834216+cblessing24@users.noreply.github.com>2022-09-03 20:44:32 +0200
committerGitHub <noreply@github.com>2022-09-03 20:44:32 +0200
commitcd7761d4fcdf1d6d3ad19b34a426a7033b41cc1a (patch)
treea88a07aa0dcce02a022ca88d9350b91b99da54db /tests/test_self.py
parentdca04df3efae7bd0508cdf36ada9d0a3271fd4b9 (diff)
downloadpylint-git-cd7761d4fcdf1d6d3ad19b34a426a7033b41cc1a.tar.gz
Do not lint ignored file on stdin (#7220)
Previously pylint would lint a file passed on stdin even if the user meant to ignore the file. This commit fixes that issue. Co-authored-by: Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>
Diffstat (limited to 'tests/test_self.py')
-rw-r--r--tests/test_self.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/test_self.py b/tests/test_self.py
index c3db103d0..a375ae6f5 100644
--- a/tests/test_self.py
+++ b/tests/test_self.py
@@ -1128,6 +1128,20 @@ a.py:1:4: E0001: Parsing failed: 'invalid syntax (<unknown>, line 1)' (syntax-er
code=0,
)
+ def test_ignore_pattern_from_stdin(self) -> None:
+ """Test if linter ignores standard input if the filename matches the ignore pattern."""
+ with mock.patch("pylint.lint.pylinter._read_stdin", return_value="import os\n"):
+ self._runtest(
+ [
+ "--from-stdin",
+ "mymodule.py",
+ "--disable=all",
+ "--enable=unused-import",
+ "--ignore-patterns=mymodule.py",
+ ],
+ code=0,
+ )
+
@pytest.mark.parametrize("ignore_path_value", [".*ignored.*", ".*failing.*"])
def test_ignore_path_recursive(self, ignore_path_value: str) -> None:
"""Tests recursive run of linter ignoring directory using --ignore-path parameter.