summaryrefslogtreecommitdiff
path: root/tests/functional/c
diff options
context:
space:
mode:
authorPierre Sassoulas <pierre.sassoulas@gmail.com>2021-03-07 22:20:00 +0100
committerPierre Sassoulas <pierre.sassoulas@gmail.com>2021-03-07 22:59:36 +0100
commitf84bf0220812a987595f719acad0be6e8cf0f982 (patch)
treea7c96e0322a8b38af55b34e57e33105528b61fb8 /tests/functional/c
parent48d366855759b612cc883409997ba161afe09095 (diff)
downloadpylint-git-f84bf0220812a987595f719acad0be6e8cf0f982.tar.gz
Migrate all func_noerror_* to new functional tests
Diffstat (limited to 'tests/functional/c')
-rw-r--r--tests/functional/c/class_attributes.py18
-rw-r--r--tests/functional/c/classes_meth_could_be_a_function.py33
-rw-r--r--tests/functional/c/classes_protected_member_access.py26
3 files changed, 77 insertions, 0 deletions
diff --git a/tests/functional/c/class_attributes.py b/tests/functional/c/class_attributes.py
new file mode 100644
index 000000000..b6fd4601e
--- /dev/null
+++ b/tests/functional/c/class_attributes.py
@@ -0,0 +1,18 @@
+"""Test that valid class attribute doesn't trigger errors"""
+__revision__ = 'sponge bob'
+# pylint: disable=useless-object-inheritance
+
+class Clazz(object):
+ "dummy class"
+
+ def __init__(self):
+ self.topic = 5
+ self._data = 45
+
+ def change_type(self, new_class):
+ """Change type"""
+ self.__class__ = new_class
+
+ def do_nothing(self):
+ "I do nothing useful"
+ return self.topic + 56
diff --git a/tests/functional/c/classes_meth_could_be_a_function.py b/tests/functional/c/classes_meth_could_be_a_function.py
new file mode 100644
index 000000000..05a6c40d7
--- /dev/null
+++ b/tests/functional/c/classes_meth_could_be_a_function.py
@@ -0,0 +1,33 @@
+# pylint: disable=C0111,R0903,W0232, useless-object-inheritance
+"""
+#2479
+
+R0201 (formely W0212), Method could be a function shouldn't be emitted in case
+like factory method pattern
+"""
+__revision__ = 1
+
+class XAsub(object):
+ pass
+class XBsub(XAsub):
+ pass
+class XCsub(XAsub):
+ pass
+
+class Aimpl(object):
+ # disable "method could be a function" on classes which are not overriding
+ # the factory method because in that case the usage of polymorphism is not
+ # detected
+ # pylint: disable=R0201
+ def makex(self):
+ return XAsub()
+
+class Bimpl(Aimpl):
+
+ def makex(self):
+ return XBsub()
+
+class Cimpl(Aimpl):
+
+ def makex(self):
+ return XCsub()
diff --git a/tests/functional/c/classes_protected_member_access.py b/tests/functional/c/classes_protected_member_access.py
new file mode 100644
index 000000000..516efd7d4
--- /dev/null
+++ b/tests/functional/c/classes_protected_member_access.py
@@ -0,0 +1,26 @@
+"""
+#3123: W0212 false positive on static method
+"""
+__revision__ = 1
+
+# pylint: disable=no-classmethod-decorator, no-staticmethod-decorator, useless-object-inheritance
+class A3123(object):
+ """oypuee"""
+ _protected = 1
+ def __init__(self):
+ pass
+
+
+ def cmeth(cls, val):
+ """set protected member"""
+ cls._protected = +val
+
+ cmeth = classmethod(cmeth)
+
+ def smeth(val):
+ """set protected member"""
+ A3123._protected += val
+
+ smeth = staticmethod(smeth)
+
+ prop = property(lambda self: self._protected)