summaryrefslogtreecommitdiff
path: root/tests/functional/t
diff options
context:
space:
mode:
authorRebecca Turner <rbt@sent.as>2021-07-28 15:45:19 -0400
committerGitHub <noreply@github.com>2021-07-28 21:45:19 +0200
commit24d03e9410520849494db1bde84334769217b3d4 (patch)
tree7b9dc434a13cf864044bb7716971136a07c05ab8 /tests/functional/t
parent67f40566c11168616079ece444fc558a81d336d2 (diff)
downloadpylint-git-24d03e9410520849494db1bde84334769217b3d4.tar.gz
Add ignored-parents option to design checker (#4758)
* Add ignored-parents option to design checker This allows users to specify classes to ignore while counting parent classes. Partially closes #3057 Co-authored-by: Pierre Sassoulas <pierre.sassoulas@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Diffstat (limited to 'tests/functional/t')
-rw-r--r--tests/functional/t/too/too_many_ancestors_ignored_parents.py40
-rw-r--r--tests/functional/t/too/too_many_ancestors_ignored_parents.rc3
-rw-r--r--tests/functional/t/too/too_many_ancestors_ignored_parents.txt1
3 files changed, 44 insertions, 0 deletions
diff --git a/tests/functional/t/too/too_many_ancestors_ignored_parents.py b/tests/functional/t/too/too_many_ancestors_ignored_parents.py
new file mode 100644
index 000000000..93598d941
--- /dev/null
+++ b/tests/functional/t/too/too_many_ancestors_ignored_parents.py
@@ -0,0 +1,40 @@
+# pylint: disable=missing-docstring, too-few-public-methods, invalid-name
+
+# Inheritance diagram:
+# F
+# /
+# D E
+# \/
+# B C
+# \/
+# A
+#
+# Once `E` is pruned from the tree, we have:
+# D
+# \
+# B C
+# \/
+# A
+#
+# By setting `max-parents=2`, we're able to check that tree-pruning works
+# correctly; in the new diagram, `B` has only 1 parent, so it doesn't raise a
+# message, and `A` has 3, so it does raise a message with the specific number
+# of parents.
+
+class F:
+ """0 parents"""
+
+class E(F):
+ """1 parent"""
+
+class D:
+ """0 parents"""
+
+class B(D, E):
+ """3 parents"""
+
+class C:
+ """0 parents"""
+
+class A(B, C): # [too-many-ancestors]
+ """5 parents"""
diff --git a/tests/functional/t/too/too_many_ancestors_ignored_parents.rc b/tests/functional/t/too/too_many_ancestors_ignored_parents.rc
new file mode 100644
index 000000000..1d06dad25
--- /dev/null
+++ b/tests/functional/t/too/too_many_ancestors_ignored_parents.rc
@@ -0,0 +1,3 @@
+[testoptions]
+max-parents=2
+ignored-parents=functional.t.too.too_many_ancestors_ignored_parents.E
diff --git a/tests/functional/t/too/too_many_ancestors_ignored_parents.txt b/tests/functional/t/too/too_many_ancestors_ignored_parents.txt
new file mode 100644
index 000000000..e1eea426a
--- /dev/null
+++ b/tests/functional/t/too/too_many_ancestors_ignored_parents.txt
@@ -0,0 +1 @@
+too-many-ancestors:39:0:A:Too many ancestors (3/2)