Skip to content

Commit e2f7f01

Browse files
author
Guido van Rossum
committed
Add an actual unit test for the lightweight type inference.
1 parent 80292ba commit e2f7f01

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

test-data/unit/check-modules.test

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -815,9 +815,12 @@ x = 0
815815
-- Test stability under import cycles
816816
-- ----------------------------------
817817

818-
-- The two tests are identical except one main has 'import x' and the other 'import y'.
818+
-- The first two tests are identical except one main has 'import x' and the other 'import y'.
819819
-- Previously (before build.order_ascc() was added) one of these would fail because the
820820
-- imports were processed in the (reverse) order in which the files were encountered.
821+
--
822+
-- The third one isn't fixed by order_ascc(), but is fixed by the lightweight type
823+
-- inference added to semanal.py (analyze_simple_literal_type()).
821824

822825
[case testImportCycleStability1]
823826
import x
@@ -846,3 +849,17 @@ import x
846849
class Sub(x.Base):
847850
attr = x.Base.attr
848851
[out]
852+
853+
[case testImportCycleStability3]
854+
import y
855+
[file x.py]
856+
class Base:
857+
pass
858+
def foo() -> int:
859+
import y
860+
return y.Sub.attr
861+
[file y.py]
862+
import x
863+
class Sub(x.Base):
864+
attr = 0
865+
[out]

0 commit comments

Comments
 (0)