Currently modifying the cache for parso doctests is not needed. So just remove it.

This commit is contained in:
Dave Halter
2017-05-17 19:12:20 -04:00
parent 799e99360c
commit 2beec09d77

View File

@@ -9,42 +9,17 @@ from parso import cache
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):
parser.addoption("--warning-is-error", action='store_true',
help="Warnings are treated as errors.")
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:
import warnings
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')
def clean_parso_cache(request):
"""
@@ -58,7 +33,7 @@ def clean_parso_cache(request):
"""
old = cache._default_cache_path
tmp = tempfile.mkdtemp(prefix='parso-test-')
cache.default_cache_path = tmp
cache._default_cache_path = tmp
@request.addfinalizer
def restore():