mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
52ca02608e
* Deprecates the --download-cache option & removes the download cache code. * Removes the in memory page cache on the index * Uses CacheControl to cache all cacheable HTTP requests to the filesystem. * Properly handles CacheControl headers for unconditional caching. * Will use ETag and Last-Modified headers to attempt to do a conditional HTTP request to speed up cache misses and turn them into cache hits. * Removes some concurrency unsafe code in the download cache accesses. * Uses a Cache-Control request header to limit the maximum length of time a cache is valid for. * Adds pip.appdirs to handle platform specific application directories such as cache, config, data, etc.
45 lines
1.5 KiB
Python
45 lines
1.5 KiB
Python
import sys
|
|
|
|
import pretend
|
|
|
|
from pip import appdirs
|
|
|
|
|
|
class TestUserCacheDir:
|
|
|
|
def test_user_cache_dir_win(self, monkeypatch):
|
|
@pretend.call_recorder
|
|
def _get_win_folder(base):
|
|
return "C:\\Users\\test\\AppData\\Local"
|
|
|
|
monkeypatch.setattr(
|
|
appdirs,
|
|
"_get_win_folder",
|
|
_get_win_folder,
|
|
raising=False,
|
|
)
|
|
monkeypatch.setattr(sys, "platform", "win32")
|
|
|
|
assert (appdirs.user_cache_dir("pip").replace("/", "\\")
|
|
== "C:\\Users\\test\\AppData\\Local\\pip\\Cache")
|
|
assert _get_win_folder.calls == [pretend.call("CSIDL_LOCAL_APPDATA")]
|
|
|
|
def test_user_cache_dir_osx(self, monkeypatch):
|
|
monkeypatch.setenv("HOME", "/home/test")
|
|
monkeypatch.setattr(sys, "platform", "darwin")
|
|
|
|
assert appdirs.user_cache_dir("pip") == "/home/test/Library/Caches/pip"
|
|
|
|
def test_user_cache_dir_linux(self, monkeypatch):
|
|
monkeypatch.delenv("XDG_CACHE_HOME")
|
|
monkeypatch.setenv("HOME", "/home/test")
|
|
monkeypatch.setattr(sys, "platform", "linux2")
|
|
|
|
assert appdirs.user_cache_dir("pip") == "/home/test/.cache/pip"
|
|
|
|
def test_user_cache_dir_linux_override(self, monkeypatch):
|
|
monkeypatch.setenv("XDG_CACHE_HOME", "/home/test/.other-cache")
|
|
monkeypatch.setenv("HOME", "/home/test")
|
|
monkeypatch.setattr(sys, "platform", "linux2")
|
|
|
|
assert appdirs.user_cache_dir("pip") == "/home/test/.other-cache/pip"
|