1
0
forked from VimPlug/jedi

Fix grammar cache problems, because multiple grammars were potentially loaded

This commit is contained in:
Dave Halter
2018-12-16 13:14:05 +01:00
parent 79189f243a
commit add33f5f80

View File

@@ -9,19 +9,20 @@ from pytest import raises
from parso import cache
from jedi import preload_module
from jedi._compatibility import is_py3
from jedi.plugins import typeshed
def test_preload_modules():
def check_loaded(*modules):
# +1 for None module (currently used)
grammar_cache = next(iter(cache.parser_cache.values()))
for grammar_cache in cache.parser_cache.values():
if None in grammar_cache:
break
# Filter the typeshed parser cache.
typeshed_cache_count = sum(
1 for path in grammar_cache
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
for i in modules:
assert [i in k for k in grammar_cache.keys() if k is not None]