summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/checkers/unittest_design.py18
-rw-r--r--tests/functional/t/too/too_few_public_methods_excluded.py14
-rw-r--r--tests/functional/t/too/too_few_public_methods_excluded.rc4
-rw-r--r--tests/functional/t/too/too_few_public_methods_excluded.txt1
4 files changed, 37 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 == []
diff --git a/tests/functional/t/too/too_few_public_methods_excluded.py b/tests/functional/t/too/too_few_public_methods_excluded.py
new file mode 100644
index 000000000..35ba873ee
--- /dev/null
+++ b/tests/functional/t/too/too_few_public_methods_excluded.py
@@ -0,0 +1,14 @@
+# pylint: disable=missing-docstring
+from json import JSONEncoder
+
+class Control: # [too-few-public-methods]
+ ...
+
+
+class MyJsonEncoder(JSONEncoder):
+ ...
+
+class InheritedInModule(Control):
+ """This class inherits from a class that doesn't have enough mehods,
+ and its parent is excluded via config, so it doesn't raise."""
+ ...
diff --git a/tests/functional/t/too/too_few_public_methods_excluded.rc b/tests/functional/t/too/too_few_public_methods_excluded.rc
new file mode 100644
index 000000000..00c025832
--- /dev/null
+++ b/tests/functional/t/too/too_few_public_methods_excluded.rc
@@ -0,0 +1,4 @@
+[testoptions]
+min-public-methods=10 # to combat inherited methods
+
+exclude-too-few-public-methods=json.*,^.*Control$
diff --git a/tests/functional/t/too/too_few_public_methods_excluded.txt b/tests/functional/t/too/too_few_public_methods_excluded.txt
new file mode 100644
index 000000000..c88cde25f
--- /dev/null
+++ b/tests/functional/t/too/too_few_public_methods_excluded.txt
@@ -0,0 +1 @@
+too-few-public-methods:4:0:Control:Too few public methods (0/10):HIGH