diff options
Diffstat (limited to 'tests/checkers/unittest_utils.py')
-rw-r--r-- | tests/checkers/unittest_utils.py | 62 |
1 files changed, 18 insertions, 44 deletions
diff --git a/tests/checkers/unittest_utils.py b/tests/checkers/unittest_utils.py index ac328d7cd..9d90d4c01 100644 --- a/tests/checkers/unittest_utils.py +++ b/tests/checkers/unittest_utils.py @@ -1,6 +1,6 @@ # 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 -# Copyright (c) https://github.com/PyCQA/pylint/blob/main/CONTRIBUTORS.txt +# For details: https://github.com/pylint-dev/pylint/blob/main/LICENSE +# Copyright (c) https://github.com/pylint-dev/pylint/blob/main/CONTRIBUTORS.txt """Tests for the pylint.checkers.utils module.""" @@ -11,7 +11,6 @@ import pytest from astroid import nodes from pylint.checkers import utils -from pylint.checkers.base_checker import BaseChecker @pytest.mark.parametrize( @@ -414,7 +413,6 @@ def test_if_sys_guard() -> None: assert utils.is_sys_guard(code[2]) is False -@pytest.mark.filterwarnings("ignore::DeprecationWarning") def test_if_typing_guard() -> None: code = astroid.extract_node( """ @@ -422,30 +420,30 @@ def test_if_typing_guard() -> None: import typing as t from typing import TYPE_CHECKING - if typing.TYPE_CHECKING: #@ - pass + if typing.TYPE_CHECKING: + pass #@ - if t.TYPE_CHECKING: #@ - pass + if t.TYPE_CHECKING: + pass #@ - if TYPE_CHECKING: #@ - pass + if TYPE_CHECKING: + pass #@ - if typing.SOME_OTHER_CONST: #@ - pass + if typing.SOME_OTHER_CONST: + pass #@ """ ) assert isinstance(code, list) and len(code) == 4 - assert isinstance(code[0], nodes.If) - assert utils.is_typing_guard(code[0]) is True - assert isinstance(code[1], nodes.If) - assert utils.is_typing_guard(code[1]) is True - assert isinstance(code[2], nodes.If) - assert utils.is_typing_guard(code[2]) is True + assert isinstance(code[0], nodes.Pass) + assert utils.in_type_checking_block(code[0]) is True + assert isinstance(code[1], nodes.Pass) + assert utils.in_type_checking_block(code[1]) is True + assert isinstance(code[2], nodes.Pass) + assert utils.in_type_checking_block(code[2]) is True - assert isinstance(code[3], nodes.If) - assert utils.is_typing_guard(code[3]) is False + assert isinstance(code[3], nodes.Pass) + assert utils.in_type_checking_block(code[3]) is False def test_in_type_checking_block() -> None: @@ -480,30 +478,6 @@ def test_is_empty_literal() -> None: assert not utils.is_empty_str_literal(not_empty_string_node.value) -def test_deprecation_is_inside_lambda() -> None: - """Test that is_inside_lambda is throwing a DeprecationWarning.""" - with pytest.warns(DeprecationWarning) as records: - utils.is_inside_lambda(nodes.NodeNG()) - assert len(records) == 1 - - -def test_deprecation_check_messages() -> None: - with pytest.warns(DeprecationWarning) as records: - - class Checker(BaseChecker): # pylint: disable=unused-variable - @utils.check_messages("my-message") - def visit_assname(self, node: nodes.NodeNG) -> None: - pass - - deprecationMessage = ( - "utils.check_messages will be removed in " - "favour of calling utils.only_required_for_messages in pylint 3.0" - ) - - assert len(records) == 1 - assert records[0].message.args[0] == deprecationMessage - - def test_is_typing_member() -> None: code = astroid.extract_node( """ |