mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-06 05:54:25 +08:00
Run py.test in clean cache directory
And finally remove XDG_CACHE_HOME=... in tox.ini.
This commit is contained in:
@@ -1,2 +1,7 @@
|
|||||||
[pytest]
|
[pytest]
|
||||||
addopts = --assert=plain
|
addopts = --assert=plain
|
||||||
|
|
||||||
|
# Activate `clean_jedi_cache` fixture for all tests. This should be
|
||||||
|
# fine as long as we are using `clean_jedi_cache` as a session scoped
|
||||||
|
# fixture.
|
||||||
|
usefixtures = clean_jedi_cache
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
|
import tempfile
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from . import base
|
from . import base
|
||||||
from . import run
|
from . import run
|
||||||
@@ -57,3 +61,25 @@ def pytest_generate_tests(metafunc):
|
|||||||
metafunc.parametrize(
|
metafunc.parametrize(
|
||||||
'refactor_case',
|
'refactor_case',
|
||||||
refactor.collect_dir_tests(base_dir, test_files))
|
refactor.collect_dir_tests(base_dir, test_files))
|
||||||
|
|
||||||
|
|
||||||
|
@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.
|
||||||
|
"""
|
||||||
|
settings = base.jedi.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,6 +1,8 @@
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from . import base
|
from . import base
|
||||||
from .run import \
|
from .run import \
|
||||||
TEST_COMPLETIONS, TEST_DEFINITIONS, TEST_ASSIGNMENTS, TEST_USAGES
|
TEST_COMPLETIONS, TEST_DEFINITIONS, TEST_ASSIGNMENTS, TEST_USAGES
|
||||||
|
|||||||
Reference in New Issue
Block a user