From add33f5f808aa404bf3c641aecf3ca4f845fcc08 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Sun, 16 Dec 2018 13:14:05 +0100 Subject: [PATCH] Fix grammar cache problems, because multiple grammars were potentially loaded --- test/test_api/test_api.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/test_api/test_api.py b/test/test_api/test_api.py index e52d504d..11d019a7 100644 --- a/test/test_api/test_api.py +++ b/test/test_api/test_api.py @@ -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]