forked from VimPlug/jedi
move cache test to the right file, #181
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
|
import time
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from jedi import settings
|
import jedi
|
||||||
|
from jedi import settings, cache
|
||||||
from jedi.cache import ParserCacheItem, _ModulePickling
|
from jedi.cache import ParserCacheItem, _ModulePickling
|
||||||
|
|
||||||
|
|
||||||
@@ -52,3 +55,21 @@ def test_modulepickling_delete_incompatible_cache():
|
|||||||
cache2.version = 2
|
cache2.version = 2
|
||||||
cached2 = load_stored_item(cache2, path, item)
|
cached2 = load_stored_item(cache2, path, item)
|
||||||
assert cached2 is None
|
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
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ Unit tests to avoid errors of the past. Makes use of Python's ``unittest``
|
|||||||
module.
|
module.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import time
|
|
||||||
import itertools
|
import itertools
|
||||||
import os
|
import os
|
||||||
import textwrap
|
import textwrap
|
||||||
@@ -21,24 +20,6 @@ from jedi import api, parsing, common
|
|||||||
|
|
||||||
|
|
||||||
class TestRegression(TestBase):
|
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):
|
def test_goto_definition_cursor(self):
|
||||||
|
|
||||||
s = ("class A():\n"
|
s = ("class A():\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user