33from pytype .tests import test_base
44
55
6- class BasicTest (test_base .BaseTest ):
6+ class RewriteTest (test_base .BaseTest ):
7+
8+ def setUp (self ):
9+ super ().setUp ()
10+ self .options .tweak (use_rewrite = True )
11+
12+
13+ class BasicTest (RewriteTest ):
714 """Basic functional tests."""
815
916 def setUp (self ):
@@ -90,6 +97,10 @@ def __init__(self) -> None: ...
9097 def f(self) -> int: ...
9198 """ )
9299
100+
101+ class ImportsTest (RewriteTest ):
102+ """Import tests."""
103+
93104 def test_import (self ):
94105 self .Check ("""
95106 import os
@@ -102,6 +113,38 @@ def test_builtins(self):
102113 assert_type(__builtins__.int, "Type[int]")
103114 """ )
104115
116+ def test_dotted_import (self ):
117+ self .Check ("""
118+ import os.path
119+ assert_type(os.path, "module")
120+ """ )
121+
122+ @test_base .skip ('Not yet implemented' )
123+ def test_from_import (self ):
124+ self .Check ("""
125+ from os import name, path
126+ assert_type(name, "str")
127+ assert_type(path, "module")
128+ """ )
129+
130+ @test_base .skip ('Not yet implemented' )
131+ def test_errors (self ):
132+ self .CheckWithErrors ("""
133+ import nonsense # import-error
134+ import os.nonsense # import-error
135+ from os import nonsense # import-error
136+ """ )
137+
138+ def test_aliases (self ):
139+ self .Check ("""
140+ import os as so
141+ assert_type(so.name, "str")
142+
143+ # Not yet implemented:
144+ # import os.path as path1
145+ # from os import path as path2
146+ """ )
147+
105148
106149if __name__ == '__main__' :
107150 test_base .main ()
0 commit comments