File: conftest.py

package info (click to toggle)
emacs-jedi 0.2.7-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 352 kB
  • sloc: lisp: 1,299; python: 361; makefile: 285; sh: 8
file content (27 lines) | stat: -rw-r--r-- 690 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import shutil
import tempfile

import pytest


@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 tox.ini.
    """
    import jedi
    settings = 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)