summaryrefslogtreecommitdiff
path: root/tests/functional/s/singledispatch_functions_py3.py
diff options
context:
space:
mode:
authorPierre Sassoulas <pierre.sassoulas@gmail.com>2019-07-21 10:56:00 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2019-09-10 11:20:16 +0200
commit997d9d1ec72fce84903da4784ac56fbe30e6da1e (patch)
tree9a0ddd3ba0975e045e408d9793cce096ecaeaa75 /tests/functional/s/singledispatch_functions_py3.py
parent676ec55ff9d8f10e52b740a57e4e62a3255d6709 (diff)
downloadpylint-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/s/singledispatch_functions_py3.py')
-rw-r--r--tests/functional/s/singledispatch_functions_py3.py76
1 files changed, 76 insertions, 0 deletions
diff --git a/tests/functional/s/singledispatch_functions_py3.py b/tests/functional/s/singledispatch_functions_py3.py
new file mode 100644
index 000000000..cfd4d873c
--- /dev/null
+++ b/tests/functional/s/singledispatch_functions_py3.py
@@ -0,0 +1,76 @@
+# pylint: disable=missing-docstring,import-error,unused-import,assignment-from-no-return
+# pylint: disable=invalid-name, too-few-public-methods, useless-object-inheritance
+from __future__ import print_function
+from UNINFERABLE import uninferable_func
+
+try:
+ from functools import singledispatch
+except ImportError:
+ from singledispatch import singledispatch
+
+my_single_dispatch = singledispatch
+
+
+class FakeSingleDispatch(object):
+
+ @staticmethod
+ def register(function):
+ return function
+
+ def __call__(self, function):
+ return function
+
+fake_singledispatch_decorator = FakeSingleDispatch()
+
+@singledispatch
+def func(arg):
+ return arg
+
+
+@func.register(str)
+def _(arg):
+ return 42
+
+
+@func.register(float)
+@func.register(int)
+def _(arg):
+ return 42
+
+
+@my_single_dispatch
+def func2(arg):
+ return arg
+
+
+@func2.register(int)
+def _(arg):
+ return 42
+
+
+@singledispatch
+def with_extra_arg(arg, verbose=False):
+ if verbose:
+ print(arg)
+ return arg
+
+
+@with_extra_arg.register(str)
+def _(arg, verbose=False):
+ unused = 42 # [unused-variable]
+ return arg[::-1]
+
+
+@fake_singledispatch_decorator
+def not_single_dispatch(arg): # [unused-argument]
+ return 'not yet implemented'
+
+
+@fake_singledispatch_decorator.register(str)
+def bad_single_dispatch(arg): # [unused-argument]
+ return 42
+
+
+@fake_singledispatch_decorator.register(str)
+def bad_single_dispatch(arg): # [unused-argument, function-redefined]
+ return 24