Skip to content

Commit 6637ec3

Browse files
authored
Merge pull request #7787 from xavfernandez/drop_user_data_dir
utils.appdirs: drop unused user_data_dir function
2 parents 520e76d + 3ce1872 commit 6637ec3

File tree

2 files changed

+2
-89
lines changed

2 files changed

+2
-89
lines changed

src/pip/_internal/utils/appdirs.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ def user_config_dir(appname, roaming=True):
2828
return _appdirs.user_config_dir(appname, appauthor=False, roaming=roaming)
2929

3030

31-
def user_data_dir(appname, roaming=False):
32-
# type: (str, bool) -> str
33-
return _appdirs.user_data_dir(appname, appauthor=False, roaming=roaming)
34-
35-
3631
# for the discussion regarding site_config_dir locations
3732
# see <https://github.com/pypa/pip/issues/1733>
3833
def site_config_dirs(appname):

tests/unit/test_appdirs.py

Lines changed: 2 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -147,88 +147,6 @@ def test_site_config_dirs_linux_empty(self, monkeypatch):
147147
assert appdirs.site_config_dirs("pip") == ['/etc/xdg/pip', '/etc']
148148

149149

150-
class TestUserDataDir:
151-
152-
def test_user_data_dir_win_no_roaming(self, monkeypatch):
153-
@pretend.call_recorder
154-
def _get_win_folder(base):
155-
return "C:\\Users\\test\\AppData\\Local"
156-
157-
monkeypatch.setattr(
158-
_appdirs,
159-
"_get_win_folder",
160-
_get_win_folder,
161-
raising=False,
162-
)
163-
monkeypatch.setattr(_appdirs, "system", "win32")
164-
monkeypatch.setattr(os, "path", ntpath)
165-
166-
assert (appdirs.user_data_dir("pip") ==
167-
"C:\\Users\\test\\AppData\\Local\\pip")
168-
assert _get_win_folder.calls == [pretend.call("CSIDL_LOCAL_APPDATA")]
169-
170-
def test_user_data_dir_win_yes_roaming(self, monkeypatch):
171-
@pretend.call_recorder
172-
def _get_win_folder(base):
173-
return "C:\\Users\\test\\AppData\\Roaming"
174-
175-
monkeypatch.setattr(
176-
_appdirs,
177-
"_get_win_folder",
178-
_get_win_folder,
179-
raising=False,
180-
)
181-
monkeypatch.setattr(_appdirs, "system", "win32")
182-
monkeypatch.setattr(os, "path", ntpath)
183-
184-
assert (
185-
appdirs.user_data_dir("pip", roaming=True) ==
186-
"C:\\Users\\test\\AppData\\Roaming\\pip"
187-
)
188-
assert _get_win_folder.calls == [pretend.call("CSIDL_APPDATA")]
189-
190-
def test_user_data_dir_osx(self, monkeypatch):
191-
monkeypatch.setattr(_appdirs, "system", "darwin")
192-
monkeypatch.setattr(os, "path", posixpath)
193-
monkeypatch.setenv("HOME", "/home/test")
194-
monkeypatch.setattr(sys, "platform", "darwin")
195-
196-
if os.path.isdir('/home/test/Library/Application Support/'):
197-
assert (appdirs.user_data_dir("pip") ==
198-
"/home/test/Library/Application Support/pip")
199-
else:
200-
assert (appdirs.user_data_dir("pip") ==
201-
"/home/test/.config/pip")
202-
203-
def test_user_data_dir_linux(self, monkeypatch):
204-
monkeypatch.setattr(_appdirs, "system", "linux2")
205-
monkeypatch.setattr(os, "path", posixpath)
206-
monkeypatch.delenv("XDG_DATA_HOME", raising=False)
207-
monkeypatch.setenv("HOME", "/home/test")
208-
monkeypatch.setattr(sys, "platform", "linux2")
209-
210-
assert appdirs.user_data_dir("pip") == "/home/test/.local/share/pip"
211-
212-
def test_user_data_dir_linux_override(self, monkeypatch):
213-
monkeypatch.setattr(_appdirs, "system", "linux2")
214-
monkeypatch.setattr(os, "path", posixpath)
215-
monkeypatch.setenv("XDG_DATA_HOME", "/home/test/.other-share")
216-
monkeypatch.setenv("HOME", "/home/test")
217-
monkeypatch.setattr(sys, "platform", "linux2")
218-
219-
assert appdirs.user_data_dir("pip") == "/home/test/.other-share/pip"
220-
221-
def test_user_data_dir_linux_home_slash(self, monkeypatch):
222-
monkeypatch.setattr(_appdirs, "system", "linux2")
223-
monkeypatch.setattr(os, "path", posixpath)
224-
# Verify that we are not affected by https://bugs.python.org/issue14768
225-
monkeypatch.delenv("XDG_DATA_HOME", raising=False)
226-
monkeypatch.setenv("HOME", "/")
227-
monkeypatch.setattr(sys, "platform", "linux2")
228-
229-
assert appdirs.user_data_dir("pip") == "/.local/share/pip"
230-
231-
232150
class TestUserConfigDir:
233151

234152
def test_user_config_dir_win_no_roaming(self, monkeypatch):
@@ -276,10 +194,10 @@ def test_user_config_dir_osx(self, monkeypatch):
276194
monkeypatch.setattr(sys, "platform", "darwin")
277195

278196
if os.path.isdir('/home/test/Library/Application Support/'):
279-
assert (appdirs.user_data_dir("pip") ==
197+
assert (appdirs.user_config_dir("pip") ==
280198
"/home/test/Library/Application Support/pip")
281199
else:
282-
assert (appdirs.user_data_dir("pip") ==
200+
assert (appdirs.user_config_dir("pip") ==
283201
"/home/test/.config/pip")
284202

285203
def test_user_config_dir_linux(self, monkeypatch):

0 commit comments

Comments
 (0)