forked from VimPlug/jedi
Fix grammar cache problems, because multiple grammars were potentially loaded
This commit is contained in:
@@ -9,19 +9,20 @@ from pytest import raises
|
|||||||
from parso import cache
|
from parso import cache
|
||||||
|
|
||||||
from jedi import preload_module
|
from jedi import preload_module
|
||||||
from jedi._compatibility import is_py3
|
|
||||||
from jedi.plugins import typeshed
|
from jedi.plugins import typeshed
|
||||||
|
|
||||||
|
|
||||||
def test_preload_modules():
|
def test_preload_modules():
|
||||||
def check_loaded(*modules):
|
def check_loaded(*modules):
|
||||||
# +1 for None module (currently used)
|
for grammar_cache in cache.parser_cache.values():
|
||||||
grammar_cache = next(iter(cache.parser_cache.values()))
|
if None in grammar_cache:
|
||||||
|
break
|
||||||
# Filter the typeshed parser cache.
|
# Filter the typeshed parser cache.
|
||||||
typeshed_cache_count = sum(
|
typeshed_cache_count = sum(
|
||||||
1 for path in grammar_cache
|
1 for path in grammar_cache
|
||||||
if path is not None and path.startswith(typeshed._TYPESHED_PATH)
|
if path is not None and path.startswith(typeshed._TYPESHED_PATH)
|
||||||
)
|
)
|
||||||
|
# +1 for None module (currently used)
|
||||||
assert len(grammar_cache) - typeshed_cache_count == len(modules) + 1
|
assert len(grammar_cache) - typeshed_cache_count == len(modules) + 1
|
||||||
for i in modules:
|
for i in modules:
|
||||||
assert [i in k for k in grammar_cache.keys() if k is not None]
|
assert [i in k for k in grammar_cache.keys() if k is not None]
|
||||||
|
|||||||
Reference in New Issue
Block a user