@@ -1037,6 +1037,8 @@ def test_relative_import_completions(self):
10371037 (None , "from . import readl\t \n " , "from . import readl" ),
10381038 ("_pyrepl" , "from .readl\t \n " , "from .readline" ),
10391039 ("_pyrepl" , "from . import readl\t \n " , "from . import readline" ),
1040+ ("_pyrepl" , "from .. import toodeep\t \n " , "from .. import toodeep" ),
1041+ ("concurrent" , "from .futures.i\t \n " , "from .futures.interpreter" ),
10401042 )
10411043 for package , code , expected in cases :
10421044 with self .subTest (code = code ):
@@ -1075,6 +1077,18 @@ def test_no_fallback_on_regular_completion(self):
10751077 output = reader .readline ()
10761078 self .assertEqual (output , expected )
10771079
1080+ def test_global_cache (self ):
1081+ with (tempfile .TemporaryDirectory () as _dir1 ,
1082+ patch .object (sys , "path" , [_dir1 , * sys .path ])):
1083+ dir1 = pathlib .Path (_dir1 )
1084+ (dir1 / "mod_aa.py" ).mkdir ()
1085+ (dir1 / "mod_bb.py" ).mkdir ()
1086+ events = code_to_events ("import mod_a\t \n import mod_b\t \n " )
1087+ reader = self .prepare_reader (events , namespace = {})
1088+ output_1 , output_2 = reader .readline (), reader .readline ()
1089+ self .assertEqual (output_1 , "import mod_aa" )
1090+ self .assertEqual (output_2 , "import mod_bb" )
1091+
10781092 def test_hardcoded_stdlib_submodules (self ):
10791093 cases = (
10801094 ("import collections.\t \n " , "import collections.abc" ),
@@ -1203,6 +1217,7 @@ def test_parse_error(self):
12031217 'import ..foo' ,
12041218 'import .foo.bar' ,
12051219 'import foo; x = 1' ,
1220+ 'import foo; 1,' ,
12061221 'import a.; x = 1' ,
12071222 'import a.b; x = 1' ,
12081223 'import a.b.; x = 1' ,
@@ -1222,6 +1237,8 @@ def test_parse_error(self):
12221237 'from foo import import' ,
12231238 'from foo import from' ,
12241239 'from foo import as' ,
1240+ 'from \\ x' , # _tokenize SyntaxError -> tokenize TokenError
1241+ 'if 1:\n pass\n \t pass' , # _tokenize TabError -> tokenize TabError
12251242 )
12261243 for code in cases :
12271244 parser = ImportParser (code )
0 commit comments