mirror of https://github.com/pypa/pip
don't try to load the state file if it does not exist
This commit is contained in:
parent
28d7dce042
commit
919554ce63
|
@ -73,8 +73,11 @@ class GlobalSelfCheckState(object):
|
|||
|
||||
# Attempt to write out our version check file
|
||||
with lockfile.LockFile(self.statefile_path):
|
||||
with open(self.statefile_path) as statefile:
|
||||
state = json.load(statefile)
|
||||
if os.path.exists(self.statefile_path):
|
||||
with open(self.statefile_path) as statefile:
|
||||
state = json.load(statefile)
|
||||
else:
|
||||
state = {}
|
||||
|
||||
state[sys.prefix] = {
|
||||
"last_check": current_time.strftime(SELFCHECK_DATE_FMT),
|
||||
|
|
|
@ -131,6 +131,7 @@ def test_global_state(monkeypatch):
|
|||
monkeypatch.setattr(outdated, "check_path_owner", lambda p: True)
|
||||
|
||||
monkeypatch.setattr(lockfile, 'LockFile', fake_lock)
|
||||
monkeypatch.setattr(os.path, "exists", lambda p: True)
|
||||
|
||||
monkeypatch.setattr(outdated, 'running_under_virtualenv',
|
||||
pretend.call_recorder(lambda: False))
|
||||
|
|
Loading…
Reference in New Issue