forked from pypa/virtualenv
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed FileNotFoundError when directory isn't writable (pypa#1640)
- when using docker, if `user_data_dir()` isn't writable directory, `default_data_dir()` use `system temp directory` + `virtualenv`. for example, tempdir is `/tmp`, it use `/tmp/virtualenv`
- Loading branch information
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import logging | ||
import os | ||
import tempfile | ||
|
||
import appdirs | ||
|
||
from virtualenv import dirs | ||
from virtualenv.dirs import _get_default_data_folder | ||
|
||
|
||
def test_get_default_data_dir(monkeypatch): | ||
# given | ||
data_dirs = { | ||
"/.local/share": os.path.join(tempfile.gettempdir(), "virtualenv"), | ||
os.getenv('HOME'): os.path.join(os.getenv('HOME'), "virtualenv"), | ||
"/tmp/share/": os.path.join("/tmp/share", "virtualenv") | ||
} | ||
|
||
def user_data_dir(data_dir): | ||
def wrapper(appname=None, appauthor=None, version=None, roaming=False): | ||
return os.path.join(data_dir, appname) | ||
return wrapper | ||
|
||
for data_dir, expected in data_dirs.items(): | ||
monkeypatch.setattr(dirs, "user_data_dir", user_data_dir(data_dir)) | ||
|
||
# when | ||
actual = _get_default_data_folder() | ||
|
||
# then | ||
assert actual == expected |