summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Sassoulas <pierre.sassoulas@gmail.com>2021-11-22 15:21:27 +0100
committerPierre Sassoulas <pierre.sassoulas@gmail.com>2021-11-22 23:08:30 +0100
commit14f7b7cfcdeab557ee84478eb39654e029c90bfe (patch)
tree79a3be1d8c224162c3fb832ca36bf4dbeaa6b4ec
parent9e32192fe7bf77281d0dfbc107984b751983e113 (diff)
downloadpylint-git-migrate-extension-tests-to-functional.tar.gz
Migrate test for extension to functional testsmigrate-extension-tests-to-functional
This permit to upgrade the fixtures in pre-commit.
-rw-r--r--.pre-commit-config.yaml2
-rw-r--r--tests/extensions/data/overlapping_exceptions.py45
-rw-r--r--tests/extensions/data/overlapping_exceptions_py33.py18
-rw-r--r--tests/extensions/test_bad_builtin.py47
-rw-r--r--tests/extensions/test_broad_try_clause.py76
-rw-r--r--tests/extensions/test_check_mccabe.py72
-rw-r--r--tests/extensions/test_comparetozero.py60
-rw-r--r--tests/extensions/test_docstyle.py58
-rw-r--r--tests/extensions/test_elseif_used.py38
-rw-r--r--tests/extensions/test_empty_comment.py35
-rw-r--r--tests/extensions/test_emptystring.py47
-rw-r--r--tests/extensions/test_overlapping_exceptions.py88
-rw-r--r--tests/extensions/test_redefined.py54
-rw-r--r--tests/functional/b/bad_builtin_extension.py (renamed from tests/extensions/data/bad_builtin.py)0
-rw-r--r--tests/functional/b/bad_builtin_extension.rc2
-rw-r--r--tests/functional/b/bad_builtin_extension.txt2
-rw-r--r--tests/functional/b/broad_try_clause_extension.py (renamed from tests/extensions/data/broad_try_clause.py)8
-rw-r--r--tests/functional/b/broad_try_clause_extension.rc2
-rw-r--r--tests/functional/b/broad_try_clause_extension.txt4
-rw-r--r--tests/functional/c/compare_to_zero_extension.py (renamed from tests/extensions/data/compare_to_zero.py)0
-rw-r--r--tests/functional/c/compare_to_zero_extension.rc2
-rw-r--r--tests/functional/c/compare_to_zero_extension.txt4
-rw-r--r--tests/functional/d/docstyle_extension.py (renamed from tests/extensions/data/docstring.py)17
-rw-r--r--tests/functional/d/docstyle_extension.rc2
-rw-r--r--tests/functional/d/docstyle_extension.txt7
-rw-r--r--tests/functional/e/elif_checker.py (renamed from tests/extensions/data/elif.py)5
-rw-r--r--tests/functional/e/elif_checker.rc2
-rw-r--r--tests/functional/e/elif_checker.txt2
-rw-r--r--tests/functional/e/empty_comment.py (renamed from tests/extensions/data/empty_comment.py)4
-rw-r--r--tests/functional/e/empty_comment.rc2
-rw-r--r--tests/functional/e/empty_comment.txt4
-rw-r--r--tests/functional/e/empty_string_comparison.py (renamed from tests/extensions/data/empty_string_comparison.py)0
-rw-r--r--tests/functional/e/empty_string_comparison.rc2
-rw-r--r--tests/functional/e/empty_string_comparison.txt4
-rw-r--r--tests/functional/m/mccabe.py (renamed from tests/extensions/data/mccabe.py)49
-rw-r--r--tests/functional/m/mccabe.rc4
-rw-r--r--tests/functional/m/mccabe.txt15
-rw-r--r--tests/functional/o/overlapping_exceptions.py66
-rw-r--r--tests/functional/o/overlapping_exceptions.rc2
-rw-r--r--tests/functional/o/overlapping_exceptions.txt12
-rw-r--r--tests/functional/r/redefined_variable_type.py (renamed from tests/extensions/data/redefined.py)2
-rw-r--r--tests/functional/r/redefined_variable_type.rc2
-rw-r--r--tests/functional/r/redefined_variable_type.txt10
43 files changed, 204 insertions, 673 deletions
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 0cae8c0b1..2ff8c6024 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -13,7 +13,7 @@ repos:
rev: v1.4
hooks:
- id: autoflake
- exclude: &fixtures tests/functional/|tests/input|tests/extensions/data|tests/regrtest_data/|tests/data/
+ exclude: &fixtures tests/functional/|tests/input|tests/regrtest_data/|tests/data/
args:
- --in-place
- --remove-all-unused-imports
diff --git a/tests/extensions/data/overlapping_exceptions.py b/tests/extensions/data/overlapping_exceptions.py
deleted file mode 100644
index 5ee50f314..000000000
--- a/tests/extensions/data/overlapping_exceptions.py
+++ /dev/null
@@ -1,45 +0,0 @@
-# pylint: disable=missing-docstring
-
-class SomeException(Exception):
- pass
-
-class SubclassException(SomeException):
- pass
-
-AliasException = SomeException
-
-try:
- pass
-except (SomeException, SomeException): # [overlapping-except]
- pass
-
-try:
- pass
-except (SomeException, SubclassException): # [overlapping-except]
- pass
-
-try:
- pass
-except (SomeException, AliasException): # [overlapping-except]
- pass
-
-try:
- pass
-except (AliasException, SubclassException): # [overlapping-except]
- pass
-
-try:
- pass
-# +1:[overlapping-except, overlapping-except, overlapping-except]
-except (SomeException, AliasException, SubclassException):
- pass
-
-try:
- pass
-except (ArithmeticError, FloatingPointError): # [overlapping-except]
- pass
-
-try:
- pass
-except (ValueError, UnicodeDecodeError): # [overlapping-except]
- pass
diff --git a/tests/extensions/data/overlapping_exceptions_py33.py b/tests/extensions/data/overlapping_exceptions_py33.py
deleted file mode 100644
index 16d5c30d1..000000000
--- a/tests/extensions/data/overlapping_exceptions_py33.py
+++ /dev/null
@@ -1,18 +0,0 @@
-# pylint: disable=missing-docstring
-
-import socket
-
-try:
- pass
-except (IOError, OSError): # [overlapping-except]
- pass
-
-try:
- pass
-except (socket.error, OSError): # [overlapping-except]
- pass
-
-try:
- pass
-except (ConnectionError, socket.error): # [overlapping-except]
- pass
diff --git a/tests/extensions/test_bad_builtin.py b/tests/extensions/test_bad_builtin.py
deleted file mode 100644
index 4512873f0..000000000
--- a/tests/extensions/test_bad_builtin.py
+++ /dev/null
@@ -1,47 +0,0 @@
-# Copyright (c) 2016-2018, 2020 Claudiu Popa <pcmanticore@gmail.com>
-# Copyright (c) 2016-2017 Derek Gustafson <degustaf@gmail.com>
-# Copyright (c) 2019-2021 Pierre Sassoulas <pierre.sassoulas@gmail.com>
-# Copyright (c) 2019 Ashley Whetter <ashley@awhetter.co.uk>
-# Copyright (c) 2020 hippo91 <guillaume.peillex@gmail.com>
-# Copyright (c) 2020 Damien Baty <damien.baty@polyconseil.fr>
-# Copyright (c) 2021 Daniël van Noord <13665637+DanielNoord@users.noreply.github.com>
-# Copyright (c) 2021 Marc Mueller <30130371+cdce8p@users.noreply.github.com>
-
-# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
-# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
-
-"""Tests for the pylint checker in :mod:`pylint.extensions.bad_builtin
-"""
-from os import path as osp
-
-import pytest
-
-from pylint.extensions.bad_builtin import BadBuiltinChecker
-from pylint.lint import fix_import_path
-from pylint.lint.pylinter import PyLinter
-
-EXPECTED = [
- "Used builtin function 'map'. Using a list comprehension can be clearer.",
- "Used builtin function 'filter'. Using a list comprehension can be clearer.",
-]
-
-
-@pytest.fixture(scope="module")
-def checker():
- return BadBuiltinChecker
-
-
-@pytest.fixture(scope="module")
-def disable():
- return ["I"]
-
-
-def test_types_redefined(linter: PyLinter) -> None:
- elif_test = osp.join(osp.dirname(osp.abspath(__file__)), "data", "bad_builtin.py")
- with fix_import_path([elif_test]):
- linter.check([elif_test])
- msgs = sorted(linter.reporter.messages, key=lambda item: item.line)
- assert len(msgs) == 2
- for msg, expected in zip(msgs, EXPECTED):
- assert msg.symbol == "bad-builtin"
- assert msg.msg == expected
diff --git a/tests/extensions/test_broad_try_clause.py b/tests/extensions/test_broad_try_clause.py
deleted file mode 100644
index 4e38adb23..000000000
--- a/tests/extensions/test_broad_try_clause.py
+++ /dev/null
@@ -1,76 +0,0 @@
-# Copyright (c) 2019-2020 Claudiu Popa <pcmanticore@gmail.com>
-# Copyright (c) 2019-2020 Tyler Thieding <tyler@thieding.com>
-# Copyright (c) 2019 Ashley Whetter <ashley@awhetter.co.uk>
-# Copyright (c) 2020-2021 Pierre Sassoulas <pierre.sassoulas@gmail.com>
-# Copyright (c) 2020 hippo91 <guillaume.peillex@gmail.com>
-# Copyright (c) 2020 Damien Baty <damien.baty@polyconseil.fr>
-# Copyright (c) 2020 Anthony Sottile <asottile@umich.edu>
-# Copyright (c) 2021 Daniël van Noord <13665637+DanielNoord@users.noreply.github.com>
-# Copyright (c) 2021 Marc Mueller <30130371+cdce8p@users.noreply.github.com>
-
-# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
-# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
-
-"""Tests for the pylint checker in :mod:`pylint.extensions.broad_try_clause`"""
-import unittest
-from os import path as osp
-from typing import TYPE_CHECKING, Optional
-
-from pylint import checkers
-from pylint.extensions.broad_try_clause import BroadTryClauseChecker
-from pylint.lint import PyLinter
-from pylint.reporters import BaseReporter
-
-if TYPE_CHECKING:
- from pylint.reporters.ureports.nodes import Section
-
-
-class BroadTryClauseTestReporter(BaseReporter):
- def on_set_current_module(self, module: str, filepath: Optional[str]) -> None:
- self.messages = []
-
- def _display(self, layout: "Section") -> None:
- pass
-
-
-class BroadTryClauseTC(unittest.TestCase):
- _linter = PyLinter()
-
- @classmethod
- def setUpClass(cls):
- cls._linter.set_reporter(BroadTryClauseTestReporter())
- checkers.initialize(cls._linter)
- cls._linter.register_checker(BroadTryClauseChecker(cls._linter))
- cls._linter.disable("I")
-
- def test_broad_try_clause_message(self) -> None:
- broad_try_clause_test = osp.join(
- osp.dirname(osp.abspath(__file__)), "data", "broad_try_clause.py"
- )
- self._linter.check([broad_try_clause_test])
- msgs = self._linter.reporter.messages
- self.assertEqual(len(msgs), 4)
-
- self.assertEqual(msgs[0].symbol, "too-many-try-statements")
- self.assertEqual(
- msgs[0].msg, "try clause contains 3 statements, expected at most 1"
- )
- self.assertEqual(msgs[0].line, 5)
-
- self.assertEqual(msgs[1].symbol, "too-many-try-statements")
- self.assertEqual(
- msgs[1].msg, "try clause contains 3 statements, expected at most 1"
- )
- self.assertEqual(msgs[1].line, 12)
-
- self.assertEqual(msgs[2].symbol, "too-many-try-statements")
- self.assertEqual(
- msgs[2].msg, "try clause contains 4 statements, expected at most 1"
- )
- self.assertEqual(msgs[2].line, 19)
-
- self.assertEqual(msgs[3].symbol, "too-many-try-statements")
- self.assertEqual(
- msgs[3].msg, "try clause contains 7 statements, expected at most 1"
- )
- self.assertEqual(msgs[3].line, 29)
diff --git a/tests/extensions/test_check_mccabe.py b/tests/extensions/test_check_mccabe.py
deleted file mode 100644
index 14d2d37ad..000000000
--- a/tests/extensions/test_check_mccabe.py
+++ /dev/null
@@ -1,72 +0,0 @@
-# Copyright (c) 2016-2018, 2020 Claudiu Popa <pcmanticore@gmail.com>
-# Copyright (c) 2016-2017 Derek Gustafson <degustaf@gmail.com>
-# Copyright (c) 2016 Moises Lopez <moylop260@vauxoo.com>
-# Copyright (c) 2019-2021 Pierre Sassoulas <pierre.sassoulas@gmail.com>
-# Copyright (c) 2019 Ashley Whetter <ashley@awhetter.co.uk>
-# Copyright (c) 2020 hippo91 <guillaume.peillex@gmail.com>
-# Copyright (c) 2020 Damien Baty <damien.baty@polyconseil.fr>
-# Copyright (c) 2021 Daniël van Noord <13665637+DanielNoord@users.noreply.github.com>
-# Copyright (c) 2021 Marc Mueller <30130371+cdce8p@users.noreply.github.com>
-
-# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
-# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
-
-"""Tests for the pylint checker in :mod:`pylint.extensions.check_mccabe"""
-# pylint: disable=redefined-outer-name
-
-from os import path as osp
-from typing import List
-
-import pytest
-
-from pylint.extensions import mccabe
-from pylint.lint.pylinter import PyLinter
-
-EXPECTED_MSGS = [
- "'f1' is too complex. The McCabe rating is 1",
- "'f2' is too complex. The McCabe rating is 1",
- "'f3' is too complex. The McCabe rating is 3",
- "'f4' is too complex. The McCabe rating is 2",
- "'f5' is too complex. The McCabe rating is 2",
- "'f6' is too complex. The McCabe rating is 2",
- "'f7' is too complex. The McCabe rating is 3",
- "'f8' is too complex. The McCabe rating is 4",
- "'f9' is too complex. The McCabe rating is 9",
- "'method1' is too complex. The McCabe rating is 1",
- "This 'for' is too complex. The McCabe rating is 4",
- "'method3' is too complex. The McCabe rating is 2",
- "'f10' is too complex. The McCabe rating is 11",
- "'method2' is too complex. The McCabe rating is 18",
-]
-
-
-@pytest.fixture(scope="module")
-def enable():
- return ["too-complex"]
-
-
-@pytest.fixture(scope="module")
-def disable():
- return ["all"]
-
-
-@pytest.fixture(scope="module")
-def register():
- return mccabe.register
-
-
-@pytest.fixture
-def fname_mccabe_example() -> str:
- return osp.join(osp.dirname(osp.abspath(__file__)), "data", "mccabe.py")
-
-
-@pytest.mark.parametrize(
- "complexity, expected", [(0, EXPECTED_MSGS), (9, EXPECTED_MSGS[-2:])]
-)
-def test_max_mccabe_rate(
- linter: PyLinter, fname_mccabe_example: str, complexity: int, expected: List[str]
-) -> None:
- linter.global_set_option("max-complexity", complexity)
- linter.check([fname_mccabe_example])
- real_msgs = [message.msg for message in linter.reporter.messages]
- assert sorted(expected) == sorted(real_msgs)
diff --git a/tests/extensions/test_comparetozero.py b/tests/extensions/test_comparetozero.py
deleted file mode 100644
index 7b5bb1624..000000000
--- a/tests/extensions/test_comparetozero.py
+++ /dev/null
@@ -1,60 +0,0 @@
-# Copyright (c) 2016 Alexander Todorov <atodorov@otb.bg>
-# Copyright (c) 2016 Łukasz Rogalski <rogalski.91@gmail.com>
-# Copyright (c) 2017-2018, 2020 Claudiu Popa <pcmanticore@gmail.com>
-# Copyright (c) 2019-2021 Pierre Sassoulas <pierre.sassoulas@gmail.com>
-# Copyright (c) 2019 Ashley Whetter <ashley@awhetter.co.uk>
-# Copyright (c) 2020 hippo91 <guillaume.peillex@gmail.com>
-# Copyright (c) 2020 Anthony Sottile <asottile@umich.edu>
-# Copyright (c) 2021 Daniël van Noord <13665637+DanielNoord@users.noreply.github.com>
-# Copyright (c) 2021 Marc Mueller <30130371+cdce8p@users.noreply.github.com>
-
-# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
-# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
-
-"""Tests for the pylint checker in :mod:`pylint.extensions.emptystring"""
-
-import os
-import unittest
-from typing import TYPE_CHECKING, Optional
-
-from pylint import checkers
-from pylint.extensions.comparetozero import CompareToZeroChecker
-from pylint.lint import PyLinter
-from pylint.reporters import BaseReporter
-
-if TYPE_CHECKING:
- from pylint.reporters.ureports.nodes import Section
-
-
-class CompareToZeroTestReporter(BaseReporter):
- def on_set_current_module(self, module: str, filepath: Optional[str]) -> None:
- self.messages = []
-
- def _display(self, layout: "Section") -> None:
- pass
-
-
-class CompareToZeroUsedTC(unittest.TestCase):
- _linter = PyLinter()
-
- @classmethod
- def setUpClass(cls) -> None:
- cls._linter.set_reporter(CompareToZeroTestReporter())
- checkers.initialize(cls._linter)
- cls._linter.register_checker(CompareToZeroChecker(cls._linter))
- cls._linter.disable("I")
-
- def test_comparetozero_message(self) -> None:
- elif_test = os.path.join(
- os.path.dirname(os.path.abspath(__file__)), "data", "compare_to_zero.py"
- )
- self._linter.check([elif_test])
- msgs = self._linter.reporter.messages
- self.assertEqual(len(msgs), 4)
- for msg in msgs:
- self.assertEqual(msg.symbol, "compare-to-zero")
- self.assertEqual(msg.msg, "Avoid comparisons to zero")
- self.assertEqual(msgs[0].line, 6)
- self.assertEqual(msgs[1].line, 9)
- self.assertEqual(msgs[2].line, 12)
- self.assertEqual(msgs[3].line, 15)
diff --git a/tests/extensions/test_docstyle.py b/tests/extensions/test_docstyle.py
deleted file mode 100644
index 7c1d019e7..000000000
--- a/tests/extensions/test_docstyle.py
+++ /dev/null
@@ -1,58 +0,0 @@
-# Copyright (c) 2016-2018, 2020 Claudiu Popa <pcmanticore@gmail.com>
-# Copyright (c) 2016-2017 Derek Gustafson <degustaf@gmail.com>
-# Copyright (c) 2016 Luis Escobar <lescobar@vauxoo.com>
-# Copyright (c) 2019-2021 Pierre Sassoulas <pierre.sassoulas@gmail.com>
-# Copyright (c) 2019 Ashley Whetter <ashley@awhetter.co.uk>
-# Copyright (c) 2020 hippo91 <guillaume.peillex@gmail.com>
-# Copyright (c) 2021 Daniël van Noord <13665637+DanielNoord@users.noreply.github.com>
-# Copyright (c) 2021 Marc Mueller <30130371+cdce8p@users.noreply.github.com>
-
-# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
-# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
-
-"""Tests for the pylint checker in :mod:`pylint.extensions.check_docstring
-"""
-
-from os.path import abspath, dirname, join
-
-import pytest
-
-from pylint.extensions.docstyle import DocStringStyleChecker
-from pylint.lint.pylinter import PyLinter
-
-EXPECTED_MSGS = [
- "First line empty in function docstring",
- "First line empty in class docstring",
- "First line empty in method docstring",
- "Bad docstring quotes in method, expected \"\"\", given '''",
- 'Bad docstring quotes in method, expected """, given "',
- 'Bad docstring quotes in method, expected """, given \'',
- 'Bad docstring quotes in method, expected """, given \'',
-]
-
-EXPECTED_SYMBOLS = [
- "docstring-first-line-empty",
- "docstring-first-line-empty",
- "docstring-first-line-empty",
- "bad-docstring-quotes",
- "bad-docstring-quotes",
- "bad-docstring-quotes",
- "bad-docstring-quotes",
-]
-
-
-@pytest.fixture(scope="module")
-def checker():
- return DocStringStyleChecker
-
-
-def test_docstring_message(linter: PyLinter) -> None:
- docstring_test = join(dirname(abspath(__file__)), "data", "docstring.py")
- linter.check([docstring_test])
- msgs = linter.reporter.messages
- assert len(msgs) == 7
- for msg, expected_symbol, expected_msg in zip(
- msgs, EXPECTED_SYMBOLS, EXPECTED_MSGS
- ):
- assert msg.symbol == expected_symbol
- assert msg.msg == expected_msg
diff --git a/tests/extensions/test_elseif_used.py b/tests/extensions/test_elseif_used.py
deleted file mode 100644
index 994a5efcf..000000000
--- a/tests/extensions/test_elseif_used.py
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright (c) 2015-2018, 2020 Claudiu Popa <pcmanticore@gmail.com>
-# Copyright (c) 2015 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr>
-# Copyright (c) 2016-2017 Derek Gustafson <degustaf@gmail.com>
-# Copyright (c) 2019-2021 Pierre Sassoulas <pierre.sassoulas@gmail.com>
-# Copyright (c) 2019 Ashley Whetter <ashley@awhetter.co.uk>
-# Copyright (c) 2020 hippo91 <guillaume.peillex@gmail.com>
-# Copyright (c) 2020 Damien Baty <damien.baty@polyconseil.fr>
-# Copyright (c) 2021 Daniël van Noord <13665637+DanielNoord@users.noreply.github.com>
-# Copyright (c) 2021 Marc Mueller <30130371+cdce8p@users.noreply.github.com>
-
-# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
-# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
-
-"""Tests for the pylint checker in :mod:`pylint.extensions.check_elif
-"""
-from os import path as osp
-
-import pytest
-
-from pylint.extensions.check_elif import ElseifUsedChecker
-from pylint.lint.pylinter import PyLinter
-
-
-@pytest.fixture(scope="module")
-def checker():
- return ElseifUsedChecker
-
-
-def test_elseif_message(linter: PyLinter) -> None:
- elif_test = osp.join(osp.dirname(osp.abspath(__file__)), "data", "elif.py")
- linter.check([elif_test])
- msgs = linter.reporter.messages
- assert len(msgs) == 2
- for msg in msgs:
- assert msg.symbol == "else-if-used"
- assert msg.msg == 'Consider using "elif" instead of "else if"'
- assert msgs[0].line == 9
- assert msgs[1].line == 21
diff --git a/tests/extensions/test_empty_comment.py b/tests/extensions/test_empty_comment.py
deleted file mode 100644
index 42d1b51f2..000000000
--- a/tests/extensions/test_empty_comment.py
+++ /dev/null
@@ -1,35 +0,0 @@
-from pathlib import Path
-
-import pytest
-
-from pylint.extensions import empty_comment
-from pylint.lint.pylinter import PyLinter
-
-
-@pytest.fixture(scope="module")
-def checker():
- return empty_comment.CommentChecker
-
-
-@pytest.fixture(scope="module")
-def enable():
- return ["empty-comment"]
-
-
-@pytest.fixture(scope="module")
-def disable():
- return ["all"]
-
-
-def test_comment_base_case(linter: PyLinter) -> None:
- comment_test = str(Path(__file__).parent.joinpath("data", "empty_comment.py"))
- linter.check([comment_test])
- msgs = linter.reporter.messages
- assert len(msgs) == 4
- for msg in msgs:
- assert msg.symbol == "empty-comment"
- assert msg.msg == "Line with empty comment"
- assert msgs[0].line == 2
- assert msgs[1].line == 3
- assert msgs[2].line == 5
- assert msgs[3].line == 7
diff --git a/tests/extensions/test_emptystring.py b/tests/extensions/test_emptystring.py
deleted file mode 100644
index f89f9202f..000000000
--- a/tests/extensions/test_emptystring.py
+++ /dev/null
@@ -1,47 +0,0 @@
-# Copyright (c) 2016 Łukasz Rogalski <rogalski.91@gmail.com>
-# Copyright (c) 2016 Alexander Todorov <atodorov@otb.bg>
-# Copyright (c) 2017-2018, 2020 Claudiu Popa <pcmanticore@gmail.com>
-# Copyright (c) 2017 Derek Gustafson <degustaf@gmail.com>
-# Copyright (c) 2019-2021 Pierre Sassoulas <pierre.sassoulas@gmail.com>
-# Copyright (c) 2019 Ashley Whetter <ashley@awhetter.co.uk>
-# Copyright (c) 2020 hippo91 <guillaume.peillex@gmail.com>
-# Copyright (c) 2020 Damien Baty <damien.baty@polyconseil.fr>
-# Copyright (c) 2020 Anthony Sottile <asottile@umich.edu>
-# Copyright (c) 2021 Daniël van Noord <13665637+DanielNoord@users.noreply.github.com>
-# Copyright (c) 2021 Marc Mueller <30130371+cdce8p@users.noreply.github.com>
-
-# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
-# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
-
-"""Tests for the pylint checker in :mod:`pylint.extensions.emptystring
-"""
-from os import path as osp
-
-import pytest
-
-from pylint.extensions.emptystring import CompareToEmptyStringChecker
-from pylint.lint.pylinter import PyLinter
-
-
-@pytest.fixture(scope="module")
-def checker():
- return CompareToEmptyStringChecker
-
-
-@pytest.fixture(scope="module")
-def disable():
- return ["I"]
-
-
-def test_emptystring_message(linter: PyLinter) -> None:
- elif_test = osp.join(
- osp.dirname(osp.abspath(__file__)), "data", "empty_string_comparison.py"
- )
- linter.check([elif_test])
- msgs = linter.reporter.messages
- expected_lineno = [6, 9, 12, 15]
- assert len(msgs) == len(expected_lineno)
- for msg, lineno in zip(msgs, expected_lineno):
- assert msg.symbol == "compare-to-empty-string"
- assert msg.msg == "Avoid comparisons to empty string"
- assert msg.line == lineno
diff --git a/tests/extensions/test_overlapping_exceptions.py b/tests/extensions/test_overlapping_exceptions.py
deleted file mode 100644
index 005e0bcf9..000000000
--- a/tests/extensions/test_overlapping_exceptions.py
+++ /dev/null
@@ -1,88 +0,0 @@
-# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
-# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
-
-"""Tests for the pylint checker in :mod:`pylint.extensions.overlapping_exceptions
-"""
-
-from os.path import dirname, join
-
-import pytest
-
-from pylint.extensions.overlapping_exceptions import OverlappingExceptionsChecker
-from pylint.lint.pylinter import PyLinter
-
-
-@pytest.fixture(scope="module")
-def checker():
- return OverlappingExceptionsChecker
-
-
-@pytest.fixture(scope="module")
-def disable():
- return ["I"]
-
-
-def test_overlapping_exceptions(linter: PyLinter) -> None:
- test = join(dirname(__file__), "data", "overlapping_exceptions.py")
- linter.check([test])
- msgs = linter.reporter.messages
-
- expected = [
- (13, "Overlapping exceptions (SomeException and SomeException are the same)"),
- (
- 18,
- "Overlapping exceptions (SomeException is an ancestor class of SubclassException)",
- ),
- (23, "Overlapping exceptions (SomeException and AliasException are the same)"),
- (
- 28,
- "Overlapping exceptions (AliasException is an ancestor class of SubclassException)",
- ),
- (34, "Overlapping exceptions (SomeException and AliasException are the same)"),
- (
- 34,
- "Overlapping exceptions (SomeException is an ancestor class of SubclassException)",
- ),
- (
- 34,
- "Overlapping exceptions (AliasException is an ancestor class of SubclassException)",
- ),
- (
- 39,
- "Overlapping exceptions (ArithmeticError is an ancestor class of FloatingPointError)",
- ),
- (
- 44,
- "Overlapping exceptions (ValueError is an ancestor class of UnicodeDecodeError)",
- ),
- ]
-
- assert len(msgs) == len(expected)
- for msg, exp in zip(msgs, expected):
- assert msg.msg_id == "W0714"
- assert msg.symbol == "overlapping-except"
- assert msg.category == "warning"
- assert (msg.line, msg.msg) == exp
-
-
-def test_overlapping_exceptions_py33(linter: PyLinter) -> None:
- """From Python 3.3 both IOError and socket.error are aliases for OSError."""
- test = join(dirname(__file__), "data", "overlapping_exceptions_py33.py")
- linter.check([test])
- msgs = linter.reporter.messages
-
- expected = [
- (7, "Overlapping exceptions (IOError and OSError are the same)"),
- (12, "Overlapping exceptions (socket.error and OSError are the same)"),
- (
- 17,
- "Overlapping exceptions (socket.error is an ancestor class of ConnectionError)",
- ),
- ]
-
- assert len(msgs) == len(expected)
- for msg, exp in zip(msgs, expected):
- assert msg.msg_id == "W0714"
- assert msg.symbol == "overlapping-except"
- assert msg.category == "warning"
- assert (msg.line, msg.msg) == exp
diff --git a/tests/extensions/test_redefined.py b/tests/extensions/test_redefined.py
deleted file mode 100644
index 1f945bf79..000000000
--- a/tests/extensions/test_redefined.py
+++ /dev/null
@@ -1,54 +0,0 @@
-# Copyright (c) 2016-2020 Claudiu Popa <pcmanticore@gmail.com>
-# Copyright (c) 2016-2017 Derek Gustafson <degustaf@gmail.com>
-# Copyright (c) 2019-2021 Pierre Sassoulas <pierre.sassoulas@gmail.com>
-# Copyright (c) 2019 Ashley Whetter <ashley@awhetter.co.uk>
-# Copyright (c) 2020 hippo91 <guillaume.peillex@gmail.com>
-# Copyright (c) 2020 Damien Baty <damien.baty@polyconseil.fr>
-# Copyright (c) 2021 Daniël van Noord <13665637+DanielNoord@users.noreply.github.com>
-# Copyright (c) 2021 Marc Mueller <30130371+cdce8p@users.noreply.github.com>
-
-# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
-# For details: https://github.com/PyCQA/pylint/blob/main/LICENSE
-
-"""Tests for the pylint checker in :mod:`pylint.extensions.check_elif"""
-from os import path as osp
-
-import pytest
-
-from pylint.extensions.redefined_variable_type import MultipleTypesChecker
-from pylint.lint import fix_import_path
-from pylint.lint.pylinter import PyLinter
-
-EXPECTED = [
- "Redefinition of self.var1 type from int to float",
- "Redefinition of a_str type from bool to float",
- "Redefinition of var type from int to str",
- "Redefinition of myint type from int to bool",
- "Redefinition of _OK type from bool to str",
- "Redefinition of instance type from redefined.MyClass to bool",
- "Redefinition of SOME_FLOAT type from float to int",
- "Redefinition of var3 type from str to int",
- "Redefinition of var type from bool to int",
- "Redefinition of var4 type from float to str",
-]
-
-
-@pytest.fixture(scope="module")
-def checker():
- return MultipleTypesChecker
-
-
-@pytest.fixture(scope="module")
-def disable():
- return ["I"]
-
-
-def test_types_redefined(linter: PyLinter) -> None:
- elif_test = osp.join(osp.dirname(osp.abspath(__file__)), "data", "redefined.py")
- with fix_import_path([elif_test]):
- linter.check([elif_test])
- msgs = sorted(linter.reporter.messages, key=lambda item: item.line)
- assert len(msgs) == 10
- for msg, expected in zip(msgs, EXPECTED):
- assert msg.symbol == "redefined-variable-type"
- assert msg.msg == expected
diff --git a/tests/extensions/data/bad_builtin.py b/tests/functional/b/bad_builtin_extension.py
index fd3e5c054..fd3e5c054 100644
--- a/tests/extensions/data/bad_builtin.py
+++ b/tests/functional/b/bad_builtin_extension.py
diff --git a/tests/functional/b/bad_builtin_extension.rc b/tests/functional/b/bad_builtin_extension.rc
new file mode 100644
index 000000000..de9b4244a
--- /dev/null
+++ b/tests/functional/b/bad_builtin_extension.rc
@@ -0,0 +1,2 @@
+[MASTER]
+load-plugins=pylint.extensions.bad_builtin,
diff --git a/tests/functional/b/bad_builtin_extension.txt b/tests/functional/b/bad_builtin_extension.txt
new file mode 100644
index 000000000..e074657b2
--- /dev/null
+++ b/tests/functional/b/bad_builtin_extension.txt
@@ -0,0 +1,2 @@
+bad-builtin:3:7::Used builtin function 'map'. Using a list comprehension can be clearer.:HIGH
+bad-builtin:4:8::Used builtin function 'filter'. Using a list comprehension can be clearer.:HIGH
diff --git a/tests/extensions/data/broad_try_clause.py b/tests/functional/b/broad_try_clause_extension.py
index 2bbc4e7a2..6fc85c6b2 100644
--- a/tests/extensions/data/broad_try_clause.py
+++ b/tests/functional/b/broad_try_clause_extension.py
@@ -2,21 +2,21 @@
MY_DICTIONARY = {"key_one": 1, "key_two": 2, "key_three": 3}
-try: # [max-try-statements]
+try: # [too-many-try-statements]
value = MY_DICTIONARY["key_one"]
value += 1
print("This one has an except clause only.")
except KeyError:
pass
-try: # [max-try-statements]
+try: # [too-many-try-statements]
value = MY_DICTIONARY["key_one"]
value += 1
print("This one has a finally clause only.")
finally:
pass
-try: # [max-try-statements]
+try: # [too-many-try-statements]
value = MY_DICTIONARY["key_one"]
value += 1
print("This one has an except clause...")
@@ -26,7 +26,7 @@ except KeyError:
finally:
pass
-try: # [max-try-statements]
+try: # [too-many-try-statements]
if "key_one" in MY_DICTIONARY:
entered_if_body = True
print("This verifies that content inside of an if statement is counted too.")
diff --git a/tests/functional/b/broad_try_clause_extension.rc b/tests/functional/b/broad_try_clause_extension.rc
new file mode 100644
index 000000000..1737783e0
--- /dev/null
+++ b/tests/functional/b/broad_try_clause_extension.rc
@@ -0,0 +1,2 @@
+[MASTER]
+load-plugins=pylint.extensions.broad_try_clause,
diff --git a/tests/functional/b/broad_try_clause_extension.txt b/tests/functional/b/broad_try_clause_extension.txt
new file mode 100644
index 000000000..8f97f9b24
--- /dev/null
+++ b/tests/functional/b/broad_try_clause_extension.txt
@@ -0,0 +1,4 @@
+too-many-try-statements:5:0::try clause contains 3 statements, expected at most 1:HIGH
+too-many-try-statements:12:0::try clause contains 3 statements, expected at most 1:HIGH
+too-many-try-statements:19:0::try clause contains 4 statements, expected at most 1:HIGH
+too-many-try-statements:29:0::try clause contains 7 statements, expected at most 1:HIGH
diff --git a/tests/extensions/data/compare_to_zero.py b/tests/functional/c/compare_to_zero_extension.py
index 29fd13994..29fd13994 100644
--- a/tests/extensions/data/compare_to_zero.py
+++ b/tests/functional/c/compare_to_zero_extension.py
diff --git a/tests/functional/c/compare_to_zero_extension.rc b/tests/functional/c/compare_to_zero_extension.rc
new file mode 100644
index 000000000..e9b836539
--- /dev/null
+++ b/tests/functional/c/compare_to_zero_extension.rc
@@ -0,0 +1,2 @@
+[MASTER]
+load-plugins=pylint.extensions.comparetozero,
diff --git a/tests/functional/c/compare_to_zero_extension.txt b/tests/functional/c/compare_to_zero_extension.txt
new file mode 100644
index 000000000..c5862e1b7
--- /dev/null
+++ b/tests/functional/c/compare_to_zero_extension.txt
@@ -0,0 +1,4 @@
+compare-to-zero:6:3::Avoid comparisons to zero:HIGH
+compare-to-zero:9:3::Avoid comparisons to zero:HIGH
+compare-to-zero:12:3::Avoid comparisons to zero:HIGH
+compare-to-zero:15:3::Avoid comparisons to zero:HIGH
diff --git a/tests/extensions/data/docstring.py b/tests/functional/d/docstyle_extension.py
index 8f34c657f..a5b6161b0 100644
--- a/tests/extensions/data/docstring.py
+++ b/tests/functional/d/docstyle_extension.py
@@ -1,35 +1,36 @@
"""Checks of Dosctrings 'docstring-first-line-empty' 'bad-docstring-quotes'"""
-def check_messages(*messages):
+def check_messages(*messages): # [docstring-first-line-empty]
"""
docstring"""
return messages
+
def function2():
"""Test Ok"""
-class FFFF:
+
+class FFFF: # [docstring-first-line-empty]
"""
Test Docstring First Line Empty
"""
- def method1(self):
+ def method1(self): # [docstring-first-line-empty, bad-docstring-quotes]
'''
Test Triple Single Quotes docstring
'''
- def method2(self):
+ def method2(self): # [bad-docstring-quotes]
"bad docstring 1"
- def method3(self):
+ def method3(self): # [bad-docstring-quotes]
'bad docstring 2'
- def method4(self):
+ def method4(self): # [bad-docstring-quotes]
' """bad docstring 3 '
- @check_messages('bad-open-mode', 'redundant-unittest-assert',
- 'deprecated-module')
+ @check_messages("bad-open-mode", "redundant-unittest-assert", "deprecated-module")
def method5(self):
"""Test OK 1 with decorators"""
diff --git a/tests/functional/d/docstyle_extension.rc b/tests/functional/d/docstyle_extension.rc
new file mode 100644
index 000000000..5128289ff
--- /dev/null
+++ b/tests/functional/d/docstyle_extension.rc
@@ -0,0 +1,2 @@
+[MASTER]
+load-plugins=pylint.extensions.docstyle,
diff --git a/tests/functional/d/docstyle_extension.txt b/tests/functional/d/docstyle_extension.txt
new file mode 100644
index 000000000..8a30eedee
--- /dev/null
+++ b/tests/functional/d/docstyle_extension.txt
@@ -0,0 +1,7 @@
+docstring-first-line-empty:4:0:check_messages:First line empty in function docstring:HIGH
+docstring-first-line-empty:14:0:FFFF:First line empty in class docstring:HIGH
+bad-docstring-quotes:19:4:FFFF.method1:"Bad docstring quotes in method, expected """""", given '''":HIGH
+docstring-first-line-empty:19:4:FFFF.method1:First line empty in method docstring:HIGH
+bad-docstring-quotes:24:4:FFFF.method2:"Bad docstring quotes in method, expected """""", given """:HIGH
+bad-docstring-quotes:27:4:FFFF.method3:"Bad docstring quotes in method, expected """""", given '":HIGH
+bad-docstring-quotes:30:4:FFFF.method4:"Bad docstring quotes in method, expected """""", given '":HIGH
diff --git a/tests/extensions/data/elif.py b/tests/functional/e/elif_checker.py
index 22e79c1db..b9722f349 100644
--- a/tests/extensions/data/elif.py
+++ b/tests/functional/e/elif_checker.py
@@ -1,12 +1,13 @@
"""Checks use of "else if" triggers a refactor message"""
+
def my_function():
"""docstring"""
myint = 2
if myint > 5:
pass
else:
- if myint <= 5:
+ if myint <= 5: # [else-if-used]
pass
else:
myint = 3
@@ -18,7 +19,7 @@ def my_function():
elif myint < 3:
pass
else:
- if myint:
+ if myint: # [else-if-used]
pass
else:
if myint:
diff --git a/tests/functional/e/elif_checker.rc b/tests/functional/e/elif_checker.rc
new file mode 100644
index 000000000..b9b1de49d
--- /dev/null
+++ b/tests/functional/e/elif_checker.rc
@@ -0,0 +1,2 @@
+[MASTER]
+load-plugins=pylint.extensions.check_elif,
diff --git a/tests/functional/e/elif_checker.txt b/tests/functional/e/elif_checker.txt
new file mode 100644
index 000000000..43d1e3b1e
--- /dev/null
+++ b/tests/functional/e/elif_checker.txt
@@ -0,0 +1,2 @@
+else-if-used:10:8:my_function:"Consider using ""elif"" instead of ""else if""":HIGH
+else-if-used:22:20:my_function:"Consider using ""elif"" instead of ""else if""":HIGH
diff --git a/tests/extensions/data/empty_comment.py b/tests/functional/e/empty_comment.py
index 8a18df2eb..6adaa4fc1 100644
--- a/tests/extensions/data/empty_comment.py
+++ b/tests/functional/e/empty_comment.py
@@ -1,9 +1,13 @@
"""empty-comment test-case"""
+# +1:[empty-comment]
A = 5 #
+# +1:[empty-comment]
#
A = '#' + '1'
+# +1:[empty-comment]
print(A) #
print("A=", A) # should not be an error#
+# +1:[empty-comment]
A = "#pe\0ace#love#" #
A = "peace#love" # \0 peace'#'''' love#peace'''-'#love'-"peace#love"#
#######
diff --git a/tests/functional/e/empty_comment.rc b/tests/functional/e/empty_comment.rc
new file mode 100644
index 000000000..1bbd021e7
--- /dev/null
+++ b/tests/functional/e/empty_comment.rc
@@ -0,0 +1,2 @@
+[MASTER]
+load-plugins=pylint.extensions.empty_comment,
diff --git a/tests/functional/e/empty_comment.txt b/tests/functional/e/empty_comment.txt
new file mode 100644
index 000000000..ae4eee33e
--- /dev/null
+++ b/tests/functional/e/empty_comment.txt
@@ -0,0 +1,4 @@
+empty-comment:3:0::Line with empty comment:HIGH
+empty-comment:5:0::Line with empty comment:HIGH
+empty-comment:8:0::Line with empty comment:HIGH
+empty-comment:11:0::Line with empty comment:HIGH
diff --git a/tests/extensions/data/empty_string_comparison.py b/tests/functional/e/empty_string_comparison.py
index c6dcf8ea8..c6dcf8ea8 100644
--- a/tests/extensions/data/empty_string_comparison.py
+++ b/tests/functional/e/empty_string_comparison.py
diff --git a/tests/functional/e/empty_string_comparison.rc b/tests/functional/e/empty_string_comparison.rc
new file mode 100644
index 000000000..e6e3ded01
--- /dev/null
+++ b/tests/functional/e/empty_string_comparison.rc
@@ -0,0 +1,2 @@
+[MASTER]
+load-plugins=pylint.extensions.emptystring,
diff --git a/tests/functional/e/empty_string_comparison.txt b/tests/functional/e/empty_string_comparison.txt
new file mode 100644
index 000000000..7e31c3d25
--- /dev/null
+++ b/tests/functional/e/empty_string_comparison.txt
@@ -0,0 +1,4 @@
+compare-to-empty-string:6:3::Avoid comparisons to empty string:HIGH
+compare-to-empty-string:9:3::Avoid comparisons to empty string:HIGH
+compare-to-empty-string:12:3::Avoid comparisons to empty string:HIGH
+compare-to-empty-string:15:3::Avoid comparisons to empty string:HIGH
diff --git a/tests/extensions/data/mccabe.py b/tests/functional/m/mccabe.py
index fdbdb5f0c..b5a257b1f 100644
--- a/tests/extensions/data/mccabe.py
+++ b/tests/functional/m/mccabe.py
@@ -1,19 +1,24 @@
+# pylint: disable=invalid-name,unnecessary-pass,no-else-return,useless-else-on-loop
+# pylint: disable=undefined-variable,consider-using-sys-exit,unused-variable,too-many-return-statements
+# pylint: disable=redefined-outer-name,useless-object-inheritance,using-constant-test,unused-argument
+# pylint: disable=broad-except, not-context-manager, no-method-argument, no-self-use, unspecified-encoding
+
"""Checks use of "too-complex" check"""
-def f1():
+def f1(): # [too-complex]
"""McCabe rating: 1"""
pass
-def f2(n):
+def f2(n): # [too-complex]
"""McCabe rating: 1"""
k = n + 4
s = k + n
return s
-def f3(n):
+def f3(n): # [too-complex]
"""McCabe rating: 3"""
if n > 3:
return "bigger than three"
@@ -23,13 +28,13 @@ def f3(n):
return "smaller than or equal to three"
-def f4():
+def f4(): # [too-complex]
"""McCabe rating: 2"""
for i in range(10):
print(i)
-def f5(mylist):
+def f5(mylist): # [too-complex]
"""McCabe rating: 2"""
for i in mylist:
print(i)
@@ -37,7 +42,7 @@ def f5(mylist):
print(None)
-def f6(n):
+def f6(n): # [too-complex]
"""McCabe rating: 2"""
if n > 4:
return f(n - 1)
@@ -45,18 +50,22 @@ def f6(n):
return n
-def f7():
+def f7(): # [too-complex]
"""McCabe rating: 3"""
+
def b():
"""McCabe rating: 2"""
+
def c():
"""McCabe rating: 1"""
pass
+
c()
+
b()
-def f8():
+def f8(): # [too-complex]
"""McCabe rating: 4"""
try:
print(1)
@@ -68,7 +77,7 @@ def f8():
print(4)
-def f9():
+def f9(): # [too-complex]
"""McCabe rating: 9"""
myint = 2
if myint > 5:
@@ -94,7 +103,7 @@ def f9():
myint = 4
-def f10():
+def f10(): # [too-complex]
"""McCabe rating: 11"""
myint = 2
if myint == 5:
@@ -123,13 +132,14 @@ def f10():
class MyClass1(object):
"""Class of example to test mccabe"""
- _name = 'MyClass' # To force a tail.node=None
- def method1():
+ _name = "MyClass" # To force a tail.node=None
+
+ def method1(): # [too-complex]
"""McCabe rating: 1"""
pass
- def method2(self, param1):
+ def method2(self, param1): # [too-complex, too-many-branches]
"""McCabe rating: 18"""
if not param1:
pass
@@ -159,7 +169,7 @@ class MyClass1(object):
pass
for count in range(6):
- with open('myfile') as fp:
+ with open("myfile") as fp:
count += 1
pass
pass
@@ -170,8 +180,8 @@ class MyClass1(object):
else:
pass
if param1:
- raise BaseException('Error')
- with open('myfile2') as fp2:
+ raise BaseException("Error")
+ with open("myfile2") as fp2:
pass
pass
finally:
@@ -180,12 +190,12 @@ class MyClass1(object):
for count2 in range(8):
try:
pass
- except BaseException('Error2'):
+ except BaseException("Error2"):
pass
return param1
-for count in range(10):
+for count in range(10): # [too-complex]
if count == 1:
exit(0)
elif count == 2:
@@ -194,7 +204,8 @@ for count in range(10):
exit(2)
-def method3(self):
+def method3(self): # [too-complex]
+ """McCabe rating: 2"""
try:
if True:
pass
diff --git a/tests/functional/m/mccabe.rc b/tests/functional/m/mccabe.rc
new file mode 100644
index 000000000..ac96a1eb5
--- /dev/null
+++ b/tests/functional/m/mccabe.rc
@@ -0,0 +1,4 @@
+[MASTER]
+load-plugins=pylint.extensions.mccabe,
+
+max-complexity=0
diff --git a/tests/functional/m/mccabe.txt b/tests/functional/m/mccabe.txt
new file mode 100644
index 000000000..3e4a8431d
--- /dev/null
+++ b/tests/functional/m/mccabe.txt
@@ -0,0 +1,15 @@
+too-complex:9:0:f1:'f1' is too complex. The McCabe rating is 1:HIGH
+too-complex:14:0:f2:'f2' is too complex. The McCabe rating is 1:HIGH
+too-complex:21:0:f3:'f3' is too complex. The McCabe rating is 3:HIGH
+too-complex:31:0:f4:'f4' is too complex. The McCabe rating is 2:HIGH
+too-complex:37:0:f5:'f5' is too complex. The McCabe rating is 2:HIGH
+too-complex:45:0:f6:'f6' is too complex. The McCabe rating is 2:HIGH
+too-complex:53:0:f7:'f7' is too complex. The McCabe rating is 3:HIGH
+too-complex:68:0:f8:'f8' is too complex. The McCabe rating is 4:HIGH
+too-complex:80:0:f9:'f9' is too complex. The McCabe rating is 9:HIGH
+too-complex:106:0:f10:'f10' is too complex. The McCabe rating is 11:HIGH
+too-complex:138:4:MyClass1.method1:'method1' is too complex. The McCabe rating is 1:HIGH
+too-complex:142:4:MyClass1.method2:'method2' is too complex. The McCabe rating is 18:HIGH
+too-many-branches:142:4:MyClass1.method2:Too many branches (20/12):HIGH
+too-complex:198:0::This 'for' is too complex. The McCabe rating is 4:HIGH
+too-complex:207:0:method3:'method3' is too complex. The McCabe rating is 2:HIGH
diff --git a/tests/functional/o/overlapping_exceptions.py b/tests/functional/o/overlapping_exceptions.py
new file mode 100644
index 000000000..c5eab48cc
--- /dev/null
+++ b/tests/functional/o/overlapping_exceptions.py
@@ -0,0 +1,66 @@
+# pylint: disable=missing-docstring
+
+import socket
+
+
+class SomeException(Exception):
+ pass
+
+
+class SubclassException(SomeException):
+ pass
+
+
+AliasException = SomeException
+
+try:
+ pass
+except (SomeException, SomeException): # [overlapping-except]
+ pass
+
+try:
+ pass
+except (SomeException, SubclassException): # [overlapping-except]
+ pass
+
+try:
+ pass
+except (SomeException, AliasException): # [overlapping-except]
+ pass
+
+try:
+ pass
+except (AliasException, SubclassException): # [overlapping-except]
+ pass
+
+try:
+ pass
+# +1:[overlapping-except, overlapping-except, overlapping-except]
+except (SomeException, AliasException, SubclassException):
+ pass
+
+try:
+ pass
+except (ArithmeticError, FloatingPointError): # [overlapping-except]
+ pass
+
+try:
+ pass
+except (ValueError, UnicodeDecodeError): # [overlapping-except]
+ pass
+
+
+try:
+ pass
+except (IOError, OSError): # [overlapping-except]
+ pass
+
+try:
+ pass
+except (socket.error, OSError): # [overlapping-except]
+ pass
+
+try:
+ pass
+except (ConnectionError, socket.error): # [overlapping-except]
+ pass
diff --git a/tests/functional/o/overlapping_exceptions.rc b/tests/functional/o/overlapping_exceptions.rc
new file mode 100644
index 000000000..ad49162c0
--- /dev/null
+++ b/tests/functional/o/overlapping_exceptions.rc
@@ -0,0 +1,2 @@
+[MASTER]
+load-plugins=pylint.extensions.overlapping_exceptions,
diff --git a/tests/functional/o/overlapping_exceptions.txt b/tests/functional/o/overlapping_exceptions.txt
new file mode 100644
index 000000000..6669ae0f8
--- /dev/null
+++ b/tests/functional/o/overlapping_exceptions.txt
@@ -0,0 +1,12 @@
+overlapping-except:18:7::Overlapping exceptions (SomeException and SomeException are the same):HIGH
+overlapping-except:23:7::Overlapping exceptions (SomeException is an ancestor class of SubclassException):HIGH
+overlapping-except:28:7::Overlapping exceptions (SomeException and AliasException are the same):HIGH
+overlapping-except:33:7::Overlapping exceptions (AliasException is an ancestor class of SubclassException):HIGH
+overlapping-except:39:7::Overlapping exceptions (AliasException is an ancestor class of SubclassException):HIGH
+overlapping-except:39:7::Overlapping exceptions (SomeException and AliasException are the same):HIGH
+overlapping-except:39:7::Overlapping exceptions (SomeException is an ancestor class of SubclassException):HIGH
+overlapping-except:44:7::Overlapping exceptions (ArithmeticError is an ancestor class of FloatingPointError):HIGH
+overlapping-except:49:7::Overlapping exceptions (ValueError is an ancestor class of UnicodeDecodeError):HIGH
+overlapping-except:55:7::Overlapping exceptions (IOError and OSError are the same):HIGH
+overlapping-except:60:7::Overlapping exceptions (socket.error and OSError are the same):HIGH
+overlapping-except:65:7::Overlapping exceptions (socket.error is an ancestor class of ConnectionError):HIGH
diff --git a/tests/extensions/data/redefined.py b/tests/functional/r/redefined_variable_type.py
index 8829c4383..aa89383d9 100644
--- a/tests/extensions/data/redefined.py
+++ b/tests/functional/r/redefined_variable_type.py
@@ -18,7 +18,7 @@ class MyClass(object):
self.a_str = "hello"
a_str = False
(a_str, b_str) = (1, 2) # no support for inference on tuple assignment
- a_str = 2.0 if self.var else 1.0
+ a_str = 2.0 if self.var else 1.0 # [redefined-variable-type]
def _getter(self):
return self.a_str
diff --git a/tests/functional/r/redefined_variable_type.rc b/tests/functional/r/redefined_variable_type.rc
new file mode 100644
index 000000000..8ee18a8f1
--- /dev/null
+++ b/tests/functional/r/redefined_variable_type.rc
@@ -0,0 +1,2 @@
+[MASTER]
+load-plugins=pylint.extensions.redefined_variable_type,
diff --git a/tests/functional/r/redefined_variable_type.txt b/tests/functional/r/redefined_variable_type.txt
new file mode 100644
index 000000000..a0205c7aa
--- /dev/null
+++ b/tests/functional/r/redefined_variable_type.txt
@@ -0,0 +1,10 @@
+redefined-variable-type:17:8:MyClass.__init__:Redefinition of self.var1 type from int to float:HIGH
+redefined-variable-type:21:8:MyClass.__init__:Redefinition of a_str type from bool to float:HIGH
+redefined-variable-type:33:12:MyClass.some_method.func:Redefinition of var type from int to str:HIGH
+redefined-variable-type:37:8:MyClass.some_method:Redefinition of myint type from int to bool:HIGH
+redefined-variable-type:39:0::Redefinition of _OK type from bool to str:HIGH
+redefined-variable-type:49:4:other_function:Redefinition of instance type from functional.r.redefined_variable_type.MyClass to bool:HIGH
+redefined-variable-type:51:0::Redefinition of SOME_FLOAT type from float to int:HIGH
+redefined-variable-type:71:8:func2:Redefinition of var3 type from str to int:HIGH
+redefined-variable-type:75:4:func2:Redefinition of var type from bool to int:HIGH
+redefined-variable-type:85:8:func2:Redefinition of var4 type from float to str:HIGH