From 4e5c2e243d603a58b30ac309e48ee23a0a9c47b0 2021-10-18 20:21:49 From: Matthias Bussonnier Date: 2021-10-18 20:21:49 Subject: [PATCH] Merge pull request #13181 from haobibo/master create ipython_dir if not exists --- diff --git a/IPython/core/tests/test_paths.py b/IPython/core/tests/test_paths.py index ab1c413..2182cb7 100644 --- a/IPython/core/tests/test_paths.py +++ b/IPython/core/tests/test_paths.py @@ -160,6 +160,10 @@ def test_get_ipython_dir_7(): @skip_win32 def test_get_ipython_dir_8(): """test_get_ipython_dir_8, test / home directory""" + if not os.access("/", os.W_OK): + # test only when HOME directory actually writable + return + with patch.object(paths, '_writable_dir', lambda path: bool(path)), \ patch.object(paths, 'get_xdg_dir', return_value=None), \ modified_env({ diff --git a/IPython/paths.py b/IPython/paths.py index 43146b0..a2ea5bc 100644 --- a/IPython/paths.py +++ b/IPython/paths.py @@ -71,6 +71,8 @@ def get_ipython_dir() -> str: warn("IPython parent '{0}' is not a writable location," " using a temp directory.".format(parent)) ipdir = tempfile.mkdtemp() + else: + os.makedirs(ipdir) assert isinstance(ipdir, str), "all path manipulation should be str(unicode), but are not." return ipdir