Skip to content

Commit bdd5de9

Browse files
ngaya-llilevkivskyi
authored andcommitted
Add enum iteration test cases (#4400)
Test cases for #2305
1 parent 91f2d36 commit bdd5de9

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

test-data/unit/pythoneval.test

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,3 +1458,48 @@ _testNoCrashOnGenericUnionUnpacking.py:10: error: Revealed type is 'Union[builti
14581458
_testNoCrashOnGenericUnionUnpacking.py:11: error: Revealed type is 'Union[builtins.str, builtins.int]'
14591459
_testNoCrashOnGenericUnionUnpacking.py:15: error: Revealed type is 'Union[builtins.int*, builtins.str*]'
14601460
_testNoCrashOnGenericUnionUnpacking.py:16: error: Revealed type is 'Union[builtins.int*, builtins.str*]'
1461+
1462+
[case testEnumIterationAndPreciseElementType]
1463+
# Regression test for #2305
1464+
from enum import Enum
1465+
class E(Enum):
1466+
A = 'a'
1467+
(reveal_type(e) for e in E)
1468+
for e in E:
1469+
reveal_type(e)
1470+
[out]
1471+
_testEnumIterationAndPreciseElementType.py:5: error: Revealed type is '_testEnumIterationAndPreciseElementType.E*'
1472+
_testEnumIterationAndPreciseElementType.py:7: error: Revealed type is '_testEnumIterationAndPreciseElementType.E*'
1473+
1474+
[case testEnumIterable]
1475+
from enum import Enum
1476+
from typing import Iterable
1477+
class E(Enum):
1478+
A = 'a'
1479+
def f(ie: Iterable[E]):
1480+
pass
1481+
f(E)
1482+
1483+
[case testIntEnumIterable]
1484+
from enum import IntEnum
1485+
from typing import Iterable
1486+
class N(IntEnum):
1487+
X = 1
1488+
def f(ni: Iterable[N]):
1489+
pass
1490+
def g(ii: Iterable[int]):
1491+
pass
1492+
f(N)
1493+
g(N)
1494+
1495+
[case testDerivedEnumIterable]
1496+
from enum import Enum
1497+
from typing import Iterable
1498+
class E(str, Enum):
1499+
A = 'foo'
1500+
def f(ei: Iterable[E]):
1501+
pass
1502+
def g(si: Iterable[str]):
1503+
pass
1504+
f(E)
1505+
g(E)

0 commit comments

Comments
 (0)