Skip to content

Commit

Permalink
Add collections.namedtuple to the test
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolevn committed Jul 29, 2023
1 parent 6257ff9 commit e4d9656
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions mypy/test/teststubtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1637,6 +1637,36 @@ class X2(NamedTuple):
error="X2.__new__",
)

@collect_cases
def test_named_tuple_typing_and_collections(self) -> Iterator[Case]:
yield Case(
stub="from typing import NamedTuple",
runtime="from collections import namedtuple",
error=None,
)
yield Case(
stub="""
class X1(NamedTuple):
bar: int
foo: str = ...
""",
runtime="""
X1 = namedtuple('X1', ['bar', 'foo'], defaults=['a'])
""",
error=None,
)
yield Case(
stub="""
class X2(NamedTuple):
bar: int
foo: str
""",
runtime="""
X2 = namedtuple('X1', ['bar', 'foo'], defaults=['a'])
""",
error="X2.__new__",
)

@collect_cases
def test_type_var(self) -> Iterator[Case]:
yield Case(
Expand Down

0 comments on commit e4d9656

Please sign in to comment.