forked from VimPlug/jedi
Use pathlib for file ios, because the new parso is out
This commit is contained in:
@@ -15,7 +15,7 @@ from test.helpers import test_dir, get_example_dir
|
||||
|
||||
|
||||
def test_preload_modules():
|
||||
def check_loaded(*modules):
|
||||
def check_loaded(*module_names):
|
||||
for grammar_cache in cache.parser_cache.values():
|
||||
if None in grammar_cache:
|
||||
break
|
||||
@@ -25,9 +25,9 @@ def test_preload_modules():
|
||||
if path is not None and str(path).startswith(str(typeshed.TYPESHED_PATH))
|
||||
)
|
||||
# +1 for None module (currently used)
|
||||
assert len(grammar_cache) - typeshed_cache_count == len(modules) + 1
|
||||
for i in modules:
|
||||
assert [i in k for k in grammar_cache.keys() if k is not None]
|
||||
assert len(grammar_cache) - typeshed_cache_count == len(module_names) + 1
|
||||
for i in module_names:
|
||||
assert [i in str(k) for k in grammar_cache.keys() if k is not None]
|
||||
|
||||
old_cache = cache.parser_cache.copy()
|
||||
cache.parser_cache.clear()
|
||||
|
||||
@@ -29,13 +29,13 @@ def test_find_module_basic():
|
||||
|
||||
def test_find_module_package():
|
||||
file_io, is_package = _find_module('json')
|
||||
assert file_io.path.endswith(os.path.join('json', '__init__.py'))
|
||||
assert file_io.path.parts[-2:] == ('json', '__init__.py')
|
||||
assert is_package is True
|
||||
|
||||
|
||||
def test_find_module_not_package():
|
||||
file_io, is_package = _find_module('io')
|
||||
assert file_io.path.endswith('io.py')
|
||||
assert file_io.path.name == 'io.py'
|
||||
assert is_package is False
|
||||
|
||||
|
||||
@@ -55,8 +55,8 @@ def test_find_module_package_zipped(Script, inference_state, environment):
|
||||
full_name='pkg'
|
||||
)
|
||||
assert file_io is not None
|
||||
assert file_io.path.endswith(os.path.join('pkg.zip', 'pkg', '__init__.py'))
|
||||
assert file_io._zip_path.endswith('pkg.zip')
|
||||
assert file_io.path.parts[-3:] == ('pkg.zip', 'pkg', '__init__.py')
|
||||
assert file_io._zip_path.name == 'pkg.zip'
|
||||
assert is_package is True
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ def test_find_module_not_package_zipped(Script, inference_state, environment):
|
||||
string='not_pkg',
|
||||
full_name='not_pkg'
|
||||
)
|
||||
assert file_io.path.endswith(os.path.join('not_pkg.zip', 'not_pkg.py'))
|
||||
assert file_io.path.parts[-2:] == ('not_pkg.zip', 'not_pkg.py')
|
||||
assert is_package is False
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user