Skip to content

Commit

Permalink
Add extra tests for __future__ annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
epenet authored Jun 28, 2024
1 parent 016f813 commit f821b46
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/test_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1834,6 +1834,39 @@ def foo() -> int:
)


def test_respect_future_import_carriage_return() -> None:
# Regression test for #385
node = parse(
dedent(
'''
"""module docstring"""
from __future__ import annotations
def foo() -> int:
return 1
'''
)
)
TypeguardTransformer().visit(node)
assert (
unparse(node)
== dedent(
'''
"""module docstring"""
from __future__ import annotations
from typeguard import TypeCheckMemo
from typeguard._functions import check_return_type
def foo() -> int:
memo = TypeCheckMemo(globals(), locals())
return check_return_type('foo', 1, int, memo)
'''
).strip()
)


def test_literal() -> None:
# Regression test for #399
node = parse(
Expand Down

0 comments on commit f821b46

Please sign in to comment.