mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-07 14:34:31 +08:00
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:
25
conftest.py
25
conftest.py
@@ -1,8 +1,9 @@
|
|||||||
import tempfile
|
import tempfile
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
import jedi
|
import pytest
|
||||||
|
|
||||||
|
import jedi
|
||||||
|
|
||||||
collect_ignore = ["setup.py"]
|
collect_ignore = ["setup.py"]
|
||||||
|
|
||||||
@@ -47,3 +48,25 @@ def pytest_unconfigure(config):
|
|||||||
global jedi_cache_directory_orig, jedi_cache_directory_temp
|
global jedi_cache_directory_orig, jedi_cache_directory_temp
|
||||||
jedi.settings.cache_directory = jedi_cache_directory_orig
|
jedi.settings.cache_directory = jedi_cache_directory_orig
|
||||||
shutil.rmtree(jedi_cache_directory_temp)
|
shutil.rmtree(jedi_cache_directory_temp)
|
||||||
|
|
||||||
|
|
||||||
|
@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)
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
import shutil
|
|
||||||
import re
|
import re
|
||||||
import tempfile
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
@@ -125,25 +123,3 @@ def isolated_jedi_cache(monkeypatch, tmpdir):
|
|||||||
"""
|
"""
|
||||||
from jedi import settings
|
from jedi import settings
|
||||||
monkeypatch.setattr(settings, 'cache_directory', str(tmpdir))
|
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)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user