提交 16528ed5 编写于 作者: T Tom Freudenheim

Cleanup per PR comments

上级 cfa65e68
Changed rules on where pip version lock file selfcheck.json is stored.
Previously, the lock file was either stored at ``USER_CACHE``/selfcheck.json,
or for vitual enviorments it is stored at ``sys.prefix``\pip-selfcheck.json
Now regardless of whether the user is in a virtual environment, the lock file
is stored either in selfcheck.json in the path specified in cache-dir in
pip.conf, or if none is specified it is stored at``USER_CACHE``/selfcheck.json
Adjust path to selfcheck.json - remove virtualenv specific path and honor cache-dir in pip.conf
......@@ -11,7 +11,6 @@ from pip._vendor.packaging import version as packaging_version
from pip._internal.compat import WINDOWS
from pip._internal.index import PackageFinder
from pip._internal.locations import USER_CACHE_DIR, running_under_virtualenv
from pip._internal.utils.filesystem import check_path_owner
from pip._internal.utils.misc import ensure_dir, get_installed_version
......@@ -21,7 +20,7 @@ SELFCHECK_DATE_FMT = "%Y-%m-%dT%H:%M:%SZ"
logger = logging.getLogger(__name__)
class GlobalSelfCheckState(object):
class SelfCheckState(object):
def __init__(self, cache_dir):
self.statefile_path = os.path.join(cache_dir, "selfcheck.json")
......@@ -74,7 +73,7 @@ def pip_version_check(session, options):
pypi_version = None
try:
state = GlobalSelfCheckState(cache_dir=options.cache_dir)
state = SelfCheckState(cache_dir=options.cache_dir)
current_time = datetime.datetime.utcnow()
# Determine if we need to refresh the state
......
......@@ -74,7 +74,7 @@ def test_pip_version_check(monkeypatch, stored_time, installed_ver, new_ver,
save=pretend.call_recorder(lambda v, t: None),
)
monkeypatch.setattr(
outdated, 'GlobalSelfCheckState', lambda **kw: fake_state
outdated, 'SelfCheckState', lambda **kw: fake_state
)
with freezegun.freeze_time(
......@@ -137,7 +137,7 @@ def test_global_state(monkeypatch, tmpdir):
monkeypatch.setattr(outdated, 'USER_CACHE_DIR', cache_dir)
monkeypatch.setattr(sys, 'prefix', tmpdir / 'pip_prefix')
state = outdated.GlobalSelfCheckState(cache_dir=cache_dir)
state = outdated.SelfCheckState(cache_dir=cache_dir)
state.save('2.0', datetime.datetime.utcnow())
expected_path = cache_dir / 'selfcheck.json'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册