diff --git a/IPython/utils/path.py b/IPython/utils/path.py index 5b6bb6d..5972503 100644 --- a/IPython/utils/path.py +++ b/IPython/utils/path.py @@ -318,6 +318,8 @@ def get_ipython_dir(): # not using XDG ipdir = home_ipdir + ipdir = os.path.normpath(os.path.expanduser(ipdir)) + return _cast_unicode(ipdir, fs_encoding) diff --git a/IPython/utils/tests/test_path.py b/IPython/utils/tests/test_path.py index 1d5ab85..0b85d2b 100644 --- a/IPython/utils/tests/test_path.py +++ b/IPython/utils/tests/test_path.py @@ -91,7 +91,7 @@ def setup_environment(): def teardown_environment(): """Restore things that were remebered by the setup_environment function """ - (oldenv, os.name, get_home_dir, IPython.__file__,) = oldstuff + (oldenv, os.name, path.get_home_dir, IPython.__file__,) = oldstuff for key in env.keys(): if key not in oldenv: @@ -269,6 +269,7 @@ def test_get_ipython_dir_4(): @with_environment def test_get_ipython_dir_5(): """test_get_ipython_dir_5, use .ipython if exists and XDG defined, but doesn't exist.""" + path.get_home_dir = lambda : HOME_TEST_DIR os.name = "posix" env.pop('IPYTHON_DIR', None) env.pop('IPYTHONDIR', None) @@ -290,6 +291,15 @@ def test_get_ipython_dir_6(): nt.assert_equal(ipdir, xdg_ipdir) @with_environment +def test_get_ipython_dir_7(): + """test_get_ipython_dir_7, test home directory expansion on IPYTHON_DIR""" + home_dir = os.path.expanduser('~/') + env['IPYTHON_DIR'] = '~/somewhere' + ipdir = path.get_ipython_dir() + nt.assert_equal(ipdir, os.path.join(home_dir, 'somewhere')) + + +@with_environment def test_get_xdg_dir_1(): """test_get_xdg_dir_1, check xdg_dir""" reload(path)