mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-07 21:34:32 +08:00
Currently modifying the cache for parso doctests is not needed. So just remove it.
This commit is contained in:
27
conftest.py
27
conftest.py
@@ -9,42 +9,17 @@ from parso import cache
|
|||||||
collect_ignore = ["setup.py"]
|
collect_ignore = ["setup.py"]
|
||||||
|
|
||||||
|
|
||||||
# The following hooks (pytest_configure, pytest_unconfigure) are used
|
|
||||||
# to modify `cache._default_cache_path` because `clean_parso_cache`
|
|
||||||
# has no effect during doctests. Without these hooks, doctests uses
|
|
||||||
# user's cache (e.g., ~/.cache/parso/). We should remove this
|
|
||||||
# workaround once the problem is fixed in py.test.
|
|
||||||
#
|
|
||||||
# See (this was back when parso was part of jedi):
|
|
||||||
# - https://github.com/davidhalter/jedi/pull/168
|
|
||||||
# - https://bitbucket.org/hpk42/pytest/issue/275/
|
|
||||||
|
|
||||||
parso_cache_directory_orig = None
|
|
||||||
parso_cache_directory_temp = None
|
|
||||||
|
|
||||||
|
|
||||||
def pytest_addoption(parser):
|
def pytest_addoption(parser):
|
||||||
parser.addoption("--warning-is-error", action='store_true',
|
parser.addoption("--warning-is-error", action='store_true',
|
||||||
help="Warnings are treated as errors.")
|
help="Warnings are treated as errors.")
|
||||||
|
|
||||||
|
|
||||||
def pytest_configure(config):
|
def pytest_configure(config):
|
||||||
global parso_cache_directory_orig, parso_cache_directory_temp
|
|
||||||
parso_cache_directory_orig = cache._default_cache_path
|
|
||||||
parso_cache_directory_temp = tempfile.mkdtemp(prefix='parso-test-')
|
|
||||||
cache._default_cache_path = parso_cache_directory_temp
|
|
||||||
|
|
||||||
if config.option.warning_is_error:
|
if config.option.warning_is_error:
|
||||||
import warnings
|
import warnings
|
||||||
warnings.simplefilter("error")
|
warnings.simplefilter("error")
|
||||||
|
|
||||||
|
|
||||||
def pytest_unconfigure(config):
|
|
||||||
global parso_cache_directory_orig, parso_cache_directory_temp
|
|
||||||
cache._default_cache_path = parso_cache_directory_orig
|
|
||||||
shutil.rmtree(parso_cache_directory_temp)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='session')
|
@pytest.fixture(scope='session')
|
||||||
def clean_parso_cache(request):
|
def clean_parso_cache(request):
|
||||||
"""
|
"""
|
||||||
@@ -58,7 +33,7 @@ def clean_parso_cache(request):
|
|||||||
"""
|
"""
|
||||||
old = cache._default_cache_path
|
old = cache._default_cache_path
|
||||||
tmp = tempfile.mkdtemp(prefix='parso-test-')
|
tmp = tempfile.mkdtemp(prefix='parso-test-')
|
||||||
cache.default_cache_path = tmp
|
cache._default_cache_path = tmp
|
||||||
|
|
||||||
@request.addfinalizer
|
@request.addfinalizer
|
||||||
def restore():
|
def restore():
|
||||||
|
|||||||
Reference in New Issue
Block a user