diff --git a/test/test_cache.py b/test/test_cache.py index c27dc705..ef9851bc 100644 --- a/test/test_cache.py +++ b/test/test_cache.py @@ -1,6 +1,9 @@ +import time + import pytest -from jedi import settings +import jedi +from jedi import settings, cache from jedi.cache import ParserCacheItem, _ModulePickling @@ -52,3 +55,21 @@ def test_modulepickling_delete_incompatible_cache(): cache2.version = 2 cached2 = load_stored_item(cache2, path, item) assert cached2 is None + + +def test_star_import_cache_duration(): + new = 0.01 + old, jedi.settings.star_import_cache_validity = \ + jedi.settings.star_import_cache_validity, new + + cache.star_import_cache = {} # first empty... + # path needs to be not-None (otherwise caching effects are not visible) + jedi.Script('', 1, 0, '').completions() + time.sleep(2 * new) + jedi.Script('', 1, 0, '').completions() + + # reset values + jedi.settings.star_import_cache_validity = old + length = len(cache.star_import_cache) + cache.star_import_cache = {} + assert length == 1 diff --git a/test/test_regression.py b/test/test_regression.py index 2e8882b5..4f08a13c 100755 --- a/test/test_regression.py +++ b/test/test_regression.py @@ -5,7 +5,6 @@ Unit tests to avoid errors of the past. Makes use of Python's ``unittest`` module. """ -import time import itertools import os import textwrap @@ -21,24 +20,6 @@ from jedi import api, parsing, common class TestRegression(TestBase): - def test_star_import_cache_duration(self): - new = 0.01 - old, jedi.settings.star_import_cache_validity = \ - jedi.settings.star_import_cache_validity, new - - cache = api.cache - cache.star_import_cache = {} # first empty... - # path needs to be not-None (otherwise caching effects are not visible) - jedi.Script('', 1, 0, '').completions() - time.sleep(2 * new) - jedi.Script('', 1, 0, '').completions() - - # reset values - jedi.settings.star_import_cache_validity = old - length = len(cache.star_import_cache) - cache.star_import_cache = {} - self.assertEqual(length, 1) - def test_goto_definition_cursor(self): s = ("class A():\n"