summaryrefslogtreecommitdiff
path: root/tests/extensions/test_while_used.py
blob: 3bf081a29ae7a2abab4efc386603477d6ec411d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
"""Tests for the pylint checker in :mod:`pylint.extensions.while
"""

import astroid

from pylint.extensions.while_used import WhileChecker
from pylint.testutils import CheckerTestCase, Message


class TestWhileUsed(CheckerTestCase):

    CHECKER_CLASS = WhileChecker

    def test_while_used(self) -> None:
        node = astroid.extract_node(
            """
        def f():
            i = 0
            while i < 10:
                i += 1
        """
        ).body[1]

        with self.assertAddsMessages(Message("while-used", node=node)):
            self.checker.visit_while(node)