1
0
forked from VimPlug/jedi

Move clean_jedi_cache fixture to top-level conftest.py

Otherwise doctest module running in jedi/ subdirectory will not find it.
This commit is contained in:
immerrr
2015-10-21 10:07:01 +03:00
parent c88f251206
commit a6512f7702
2 changed files with 24 additions and 25 deletions

View File

@@ -1,7 +1,5 @@
import os
import shutil
import re
import tempfile
import pytest
@@ -125,25 +123,3 @@ def isolated_jedi_cache(monkeypatch, tmpdir):
"""
from jedi import settings
monkeypatch.setattr(settings, 'cache_directory', str(tmpdir))
@pytest.fixture(scope='session')
def clean_jedi_cache(request):
"""
Set `jedi.settings.cache_directory` to a temporary directory during test.
Note that you can't use built-in `tmpdir` and `monkeypatch`
fixture here because their scope is 'function', which is not used
in 'session' scope fixture.
This fixture is activated in ../pytest.ini.
"""
from jedi import settings
old = settings.cache_directory
tmp = tempfile.mkdtemp(prefix='jedi-test-')
settings.cache_directory = tmp
@request.addfinalizer
def restore():
settings.cache_directory = old
shutil.rmtree(tmp)