summaryrefslogtreecommitdiff
path: root/tests/checkers
diff options
context:
space:
mode:
authorMike Fiedler <miketheman@gmail.com>2021-10-26 03:07:55 -0400
committerGitHub <noreply@github.com>2021-10-26 09:07:55 +0200
commit448485a98b66a40fae6db6dbb4f25f4516e5e539 (patch)
tree108bef8231bac4745076cc062829c832274e0f98 /tests/checkers
parent17d69269580161456c12c1112b7129f4a5cbb807 (diff)
downloadpylint-git-448485a98b66a40fae6db6dbb4f25f4516e5e539.tar.gz
Add configuration option ``exclude-too-few-public-methods`` (#5191)
Allow excluding classes based on their ancestors from the ``too-few-public-methods`` checker. Closes #3370 Signed-off-by: Mike Fiedler <miketheman@gmail.com> Co-authored-by: Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com>
Diffstat (limited to 'tests/checkers')
-rw-r--r--tests/checkers/unittest_design.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/checkers/unittest_design.py b/tests/checkers/unittest_design.py
index 5c6f38816..441793a2e 100644
--- a/tests/checkers/unittest_design.py
+++ b/tests/checkers/unittest_design.py
@@ -11,6 +11,7 @@ import astroid
from pylint.checkers import design_analysis
from pylint.testutils import CheckerTestCase, set_config
+from pylint.utils.utils import get_global_option
class TestDesignChecker(CheckerTestCase):
@@ -42,3 +43,20 @@ class TestDesignChecker(CheckerTestCase):
)
with self.assertNoMessages():
self.checker.visit_classdef(node)
+
+ @set_config(exclude_too_few_public_methods="toml.*")
+ def test_exclude_too_few_methods_with_value(self) -> None:
+ """Test exclude-too-few-public-methods option with value"""
+ options = get_global_option(self.checker, "exclude-too-few-public-methods")
+
+ assert any(i.match("toml") for i in options)
+ assert any(i.match("toml.*") for i in options)
+ assert any(i.match("toml.TomlEncoder") for i in options)
+
+ def test_ignore_paths_with_no_value(self) -> None:
+ """Test exclude-too-few-public-methods option with no value.
+ Compare against actual list to see if validator works."""
+ options = get_global_option(self.checker, "exclude-too-few-public-methods")
+
+ # pylint: disable-next=use-implicit-booleaness-not-comparison
+ assert options == []