Skip to content

Commit

Permalink
Unit test pylint.checkers.utils.is_typing_literal
Browse files Browse the repository at this point in the history
  • Loading branch information
lggruspe committed Sep 4, 2022
1 parent 63f49d0 commit 8a562df
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/checkers/unittest_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,3 +489,29 @@ def visit_assname(self, node: nodes.NodeNG) -> None:
records[0].message.args[0]
== "utils.check_messages will be removed in favour of calling utils.only_required_for_messages in pylint 3.0"
)


def test_is_typing_literal() -> None:
code = astroid.extract_node(
"""
from typing import Literal as Lit, Set as Literal
import typing as t
Literal #@
Lit #@
t.Literal #@
"""
)

assert not utils.is_typing_literal(code[0])
assert utils.is_typing_literal(code[1])
assert utils.is_typing_literal(code[2])

code = astroid.extract_node(
"""
Literal #@
typing.Literal #@
"""
)
assert not utils.is_typing_literal(code[0])
assert not utils.is_typing_literal(code[1])

0 comments on commit 8a562df

Please sign in to comment.