Skip to content

Commit 350b5d8

Browse files
committed
Update fine-grained tests to prep for --namespace-packages support
These tests were deleting package files, but not the empty directory, causing those directories to be interpreted as namespace packages in #9636
1 parent b75d935 commit 350b5d8

File tree

2 files changed

+23
-25
lines changed

2 files changed

+23
-25
lines changed

test-data/unit/fine-grained-follow-imports.test

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -418,8 +418,7 @@ def f(x: str) -> None: pass
418418
[file p/m.py.3]
419419
def f(x: str) -> None: pass
420420

421-
[delete p/m.py.4]
422-
[delete p/__init__.py.4]
421+
[delete p.4]
423422

424423
[out]
425424
==
@@ -445,8 +444,7 @@ def f(x: str) -> None: pass
445444

446445
1()
447446

448-
[delete p/m.py.3]
449-
[delete p/__init__.py.3]
447+
[delete p.3]
450448

451449
[out]
452450
==

test-data/unit/fine-grained-modules.test

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -854,8 +854,7 @@ p.f(1)
854854
from p.a import f
855855
[file p/a.py]
856856
def f(x: str) -> None: pass
857-
[delete p/__init__.py.2]
858-
[delete p/a.py.2]
857+
[delete p.2]
859858
[out]
860859
main:2: error: Argument 1 to "f" has incompatible type "int"; expected "str"
861860
==
@@ -870,7 +869,7 @@ p.a.f(1)
870869
[file p/a.py]
871870
def f(x: str) -> None: pass
872871
[delete p/a.py.2]
873-
[delete p/__init__.py.3]
872+
[delete p.3]
874873
[builtins fixtures/module.pyi]
875874
[out]
876875
main:3: error: Argument 1 to "f" has incompatible type "int"; expected "str"
@@ -884,25 +883,26 @@ main:2: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missin
884883
main:2: error: Cannot find implementation or library stub for module named "p"
885884

886885
[case testDeletePackage4]
886+
# flags: --namespace-packages
887887
import p.a
888888
p.a.f(1)
889889
[file p/a.py]
890890
def f(x: str) -> None: pass
891891
[file p/__init__.py]
892892
[delete p/__init__.py.2]
893-
[delete p/a.py.3]
893+
[delete p.3]
894894
[out]
895-
main:2: error: Argument 1 to "f" has incompatible type "int"; expected "str"
895+
main:3: error: Argument 1 to "f" has incompatible type "int"; expected "str"
896896
==
897-
main:1: error: Cannot find implementation or library stub for module named "p.a"
898-
main:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
899-
main:1: error: Cannot find implementation or library stub for module named "p"
897+
main:2: error: Import of "p.a" ignored
898+
main:2: note: (Using --follow-imports=error, module not passed on command line)
900899
==
901-
main:1: error: Cannot find implementation or library stub for module named "p.a"
902-
main:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
903-
main:1: error: Cannot find implementation or library stub for module named "p"
900+
main:2: error: Cannot find implementation or library stub for module named "p.a"
901+
main:2: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
902+
main:2: error: Cannot find implementation or library stub for module named "p"
904903

905904
[case testDeletePackage5]
905+
# flags: --namespace-packages
906906
# cmd1: mypy main p/a.py p/__init__.py
907907
# cmd2: mypy main p/a.py
908908
# cmd3: mypy main
@@ -913,20 +913,20 @@ p.a.f(1)
913913
def f(x: str) -> None: pass
914914
[file p/__init__.py]
915915
[delete p/__init__.py.2]
916-
[delete p/a.py.3]
916+
[delete p.3]
917917
[out]
918-
main:6: error: Argument 1 to "f" has incompatible type "int"; expected "str"
918+
main:7: error: Argument 1 to "f" has incompatible type "int"; expected "str"
919919
==
920-
main:5: error: Cannot find implementation or library stub for module named "p.a"
921-
main:5: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
922-
main:5: error: Cannot find implementation or library stub for module named "p"
920+
main:6: error: Import of "p.a" ignored
921+
main:6: note: (Using --follow-imports=error, module not passed on command line)
923922
==
924-
main:5: error: Cannot find implementation or library stub for module named "p.a"
925-
main:5: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
926-
main:5: error: Cannot find implementation or library stub for module named "p"
923+
main:6: error: Cannot find implementation or library stub for module named "p.a"
924+
main:6: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
925+
main:6: error: Cannot find implementation or library stub for module named "p"
927926

928927

929928
[case testDeletePackage6]
929+
# flags: --namespace-packages
930930
# cmd1: mypy p/a.py p/b.py p/__init__.py
931931
# cmd2: mypy p/a.py p/b.py
932932
# cmd3: mypy p/a.py p/b.py
@@ -943,8 +943,8 @@ f(12)
943943
[out]
944944
p/b.py:2: error: Argument 1 to "f" has incompatible type "int"; expected "str"
945945
==
946-
p/b.py:1: error: Cannot find implementation or library stub for module named "p.a"
947-
p/b.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
946+
p/b.py:1: error: Import of "p.a" ignored
947+
p/b.py:1: note: (Using --follow-imports=error, module not passed on command line)
948948
==
949949
p/b.py:2: error: Argument 1 to "f" has incompatible type "int"; expected "str"
950950

0 commit comments

Comments
 (0)