Skip to content

Commit 564fbb4

Browse files
author
Guido van Rossum
committed
Add tests for all supported literal types.
1 parent ce3b0af commit 564fbb4

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

test-data/unit/check-modules.test

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -885,3 +885,45 @@ class D:
885885
attr = 0
886886
def bar() -> str:
887887
return x.C.attr
888+
889+
-- These cases test all supported literal types.
890+
891+
[case testImportCycleStability5]
892+
import y
893+
[file x.py]
894+
class Base:
895+
pass
896+
def foo() -> None:
897+
import y
898+
i = y.Sub.iattr # type: int
899+
f = y.Sub.fattr # type: float
900+
s = y.Sub.sattr # type: str
901+
b = y.Sub.battr # type: bytes
902+
[file y.py]
903+
import x
904+
class Sub(x.Base):
905+
iattr = 0
906+
fattr = 0.0
907+
sattr = ''
908+
battr = b''
909+
[out]
910+
911+
[case testImportCycleStability6_python2]
912+
import y
913+
[file x.py]
914+
class Base:
915+
pass
916+
def foo() -> None:
917+
import y
918+
i = y.Sub.iattr # type: int
919+
f = y.Sub.fattr # type: float
920+
s = y.Sub.sattr # type: str
921+
u = y.Sub.uattr # type: unicode
922+
[file y.py]
923+
import x
924+
class Sub(x.Base):
925+
iattr = 0
926+
fattr = 0.0
927+
sattr = ''
928+
uattr = u''
929+
[out]

test-data/unit/lib-stub/__builtin__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ def __init__(self, x):
1212

1313
# These are provided here for convenience.
1414
class int: pass
15+
class float: pass
16+
1517
class str: pass
18+
class unicode: pass
1619

1720
class tuple: pass
1821
class function: pass

test-data/unit/lib-stub/builtins.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@ def __init__(self, x: Any) -> None: pass
99
# These are provided here for convenience.
1010
class int:
1111
def __add__(self, other: 'int') -> 'int': pass
12+
class float: pass
13+
1214
class str:
1315
def __add__(self, other: 'str') -> 'str': pass
16+
class bytes: pass
1417

1518
class tuple: pass
1619
class function: pass

0 commit comments

Comments
 (0)