diff options
author | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2019-07-21 10:56:00 +0200 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2019-09-10 11:20:16 +0200 |
commit | 997d9d1ec72fce84903da4784ac56fbe30e6da1e (patch) | |
tree | 9a0ddd3ba0975e045e408d9793cce096ecaeaa75 /tests/functional/p | |
parent | 676ec55ff9d8f10e52b740a57e4e62a3255d6709 (diff) | |
download | pylint-git-997d9d1ec72fce84903da4784ac56fbe30e6da1e.tar.gz |
[functional tests] Rename example_functional_tests.py => e/example_functional_tests.py
Permit to navigate in the functional tests easier.
Diffstat (limited to 'tests/functional/p')
20 files changed, 120 insertions, 0 deletions
diff --git a/tests/functional/p/postponed_evaluation_activated.py b/tests/functional/p/postponed_evaluation_activated.py new file mode 100644 index 000000000..3cc694d47 --- /dev/null +++ b/tests/functional/p/postponed_evaluation_activated.py @@ -0,0 +1,28 @@ +# pylint: disable=missing-docstring,no-self-use,unused-argument,pointless-statement +# pylint: disable=too-few-public-methods,no-name-in-module +from __future__ import annotations + + +class Class: + @classmethod + def from_string(cls, source) -> Class: + ... + + def validate_b(self, obj: OtherClass) -> bool: + ... + + +class OtherClass: + ... + + +class Example: + obj: Other + + +class Other: + ... + + +class ExampleSelf: + next: ExampleSelf diff --git a/tests/functional/p/postponed_evaluation_activated.rc b/tests/functional/p/postponed_evaluation_activated.rc new file mode 100644 index 000000000..a17bb22da --- /dev/null +++ b/tests/functional/p/postponed_evaluation_activated.rc @@ -0,0 +1,2 @@ +[testoptions] +min_pyver=3.7 diff --git a/tests/functional/p/postponed_evaluation_activated.txt b/tests/functional/p/postponed_evaluation_activated.txt new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/functional/p/postponed_evaluation_activated.txt diff --git a/tests/functional/p/postponed_evaluation_not_activated.py b/tests/functional/p/postponed_evaluation_not_activated.py new file mode 100644 index 000000000..f892414f0 --- /dev/null +++ b/tests/functional/p/postponed_evaluation_not_activated.py @@ -0,0 +1,14 @@ +# pylint: disable=missing-docstring,no-self-use,unused-argument,pointless-statement +# pylint: disable=too-few-public-methods + +class Class: + @classmethod + def from_string(cls, source) -> Class: # [undefined-variable] + ... + + def validate_b(self, obj: OtherClass) -> bool: # [used-before-assignment] + ... + + +class OtherClass: + ... diff --git a/tests/functional/p/postponed_evaluation_not_activated.rc b/tests/functional/p/postponed_evaluation_not_activated.rc new file mode 100644 index 000000000..a17bb22da --- /dev/null +++ b/tests/functional/p/postponed_evaluation_not_activated.rc @@ -0,0 +1,2 @@ +[testoptions] +min_pyver=3.7 diff --git a/tests/functional/p/postponed_evaluation_not_activated.txt b/tests/functional/p/postponed_evaluation_not_activated.txt new file mode 100644 index 000000000..cae433c42 --- /dev/null +++ b/tests/functional/p/postponed_evaluation_not_activated.txt @@ -0,0 +1,2 @@ +undefined-variable:6:Class.from_string:Undefined variable 'Class' +used-before-assignment:9:Class.validate_b:Using variable 'OtherClass' before assignment diff --git a/tests/functional/p/pragma_after_backslash.py b/tests/functional/p/pragma_after_backslash.py new file mode 100644 index 000000000..c506f6c9d --- /dev/null +++ b/tests/functional/p/pragma_after_backslash.py @@ -0,0 +1,10 @@ +"""Test that a pragma has an effect when separated by a backslash.""" +# pylint: disable=too-few-public-methods + +class Foo: + """block-disable test""" + + def meth3(self): + """test one line disabling""" + print(self.bla) \ + # pylint: disable=E1101 diff --git a/tests/functional/p/preferred_module.py b/tests/functional/p/preferred_module.py new file mode 100644 index 000000000..ce1f1c2c8 --- /dev/null +++ b/tests/functional/p/preferred_module.py @@ -0,0 +1,5 @@ +"""Test preferred modules.""" +# pylint: disable=unused-import + +import json # [preferred-module] +from re import search # [preferred-module] diff --git a/tests/functional/p/preferred_module.rc b/tests/functional/p/preferred_module.rc new file mode 100644 index 000000000..e0982e030 --- /dev/null +++ b/tests/functional/p/preferred_module.rc @@ -0,0 +1,2 @@ +[IMPORTS] +preferred-modules=json:ujson,re:regex diff --git a/tests/functional/p/preferred_module.txt b/tests/functional/p/preferred_module.txt new file mode 100644 index 000000000..7d327cac4 --- /dev/null +++ b/tests/functional/p/preferred_module.txt @@ -0,0 +1,2 @@ +preferred-module:4::Prefer importing 'ujson' instead of 'json' +preferred-module:5::Prefer importing 'regex' instead of 're' diff --git a/tests/functional/p/print_always_warns.py b/tests/functional/p/print_always_warns.py new file mode 100644 index 000000000..8b7f2fc9c --- /dev/null +++ b/tests/functional/p/print_always_warns.py @@ -0,0 +1,8 @@ +"""Check print statement always warns even if in Python 2 block """ + +from __future__ import absolute_import + +import six + +if six.PY2: + print "Python 3 fails to parse print statements." # [print-statement] diff --git a/tests/functional/p/print_always_warns.rc b/tests/functional/p/print_always_warns.rc new file mode 100644 index 000000000..4a0e47a21 --- /dev/null +++ b/tests/functional/p/print_always_warns.rc @@ -0,0 +1,5 @@ +[testoptions] +max_pyver=3.0 + +[Messages Control] +enable=python3 diff --git a/tests/functional/p/print_always_warns.txt b/tests/functional/p/print_always_warns.txt new file mode 100644 index 000000000..c35e118d4 --- /dev/null +++ b/tests/functional/p/print_always_warns.txt @@ -0,0 +1 @@ +print-statement:8::print statement used diff --git a/tests/functional/p/property_with_parameters.py b/tests/functional/p/property_with_parameters.py new file mode 100644 index 000000000..2f521991f --- /dev/null +++ b/tests/functional/p/property_with_parameters.py @@ -0,0 +1,7 @@ +# pylint: disable=missing-docstring, too-few-public-methods + + +class Cls: + @property + def attribute(self, param, param1): # [property-with-parameters] + return param + param1 diff --git a/tests/functional/p/property_with_parameters.txt b/tests/functional/p/property_with_parameters.txt new file mode 100644 index 000000000..325d89306 --- /dev/null +++ b/tests/functional/p/property_with_parameters.txt @@ -0,0 +1 @@ +property-with-parameters:6:Cls.attribute:Cannot have defined parameters for properties diff --git a/tests/functional/p/protected_access_access_different_scopes.py b/tests/functional/p/protected_access_access_different_scopes.py new file mode 100644 index 000000000..dc09aa52b --- /dev/null +++ b/tests/functional/p/protected_access_access_different_scopes.py @@ -0,0 +1,13 @@ +# pylint: disable=missing-docstring, too-few-public-methods +class MyClass: + + async def method(self): + pass + + +def function(): + assert self.attr # [undefined-variable] + + +def func(): + self.attr += 2 # [undefined-variable] diff --git a/tests/functional/p/protected_access_access_different_scopes.rc b/tests/functional/p/protected_access_access_different_scopes.rc new file mode 100644 index 000000000..71de8b630 --- /dev/null +++ b/tests/functional/p/protected_access_access_different_scopes.rc @@ -0,0 +1,2 @@ +[testoptions] +min_pyver=3.5 diff --git a/tests/functional/p/protected_access_access_different_scopes.txt b/tests/functional/p/protected_access_access_different_scopes.txt new file mode 100644 index 000000000..ab8b5be11 --- /dev/null +++ b/tests/functional/p/protected_access_access_different_scopes.txt @@ -0,0 +1,2 @@ +undefined-variable:9:function:"Undefined variable 'self'" +undefined-variable:13:func:"Undefined variable 'self'"
\ No newline at end of file diff --git a/tests/functional/p/protocol_classes.py b/tests/functional/p/protocol_classes.py new file mode 100644 index 000000000..0399c94e5 --- /dev/null +++ b/tests/functional/p/protocol_classes.py @@ -0,0 +1,12 @@ +# pylint: disable=missing-docstring +import typing + + +class Hasher(typing.Protocol): + """A hashing algorithm, e.g. :func:`hashlib.sha256`.""" + + def update(self, blob: bytes): + ... + + def digest(self) -> bytes: + ... diff --git a/tests/functional/p/protocol_classes.rc b/tests/functional/p/protocol_classes.rc new file mode 100644 index 000000000..85fc502b3 --- /dev/null +++ b/tests/functional/p/protocol_classes.rc @@ -0,0 +1,2 @@ +[testoptions] +min_pyver=3.8 |