Show More
@@ -68,7 +68,7 b' def test_get_ipython_dir_2():' | |||||
68 | assert ipdir == os.path.join("someplace", ".ipython") |
|
68 | assert ipdir == os.path.join("someplace", ".ipython") | |
69 |
|
69 | |||
70 | def test_get_ipython_dir_3(): |
|
70 | def test_get_ipython_dir_3(): | |
71 |
"""test_get_ipython_dir_3, |
|
71 | """test_get_ipython_dir_3, use XDG if defined and exists, and .ipython doesn't exist.""" | |
72 | tmphome = TemporaryDirectory() |
|
72 | tmphome = TemporaryDirectory() | |
73 | try: |
|
73 | try: | |
74 | with patch_get_home_dir(tmphome.name), \ |
|
74 | with patch_get_home_dir(tmphome.name), \ | |
@@ -80,10 +80,8 b' def test_get_ipython_dir_3():' | |||||
80 | }), warnings.catch_warnings(record=True) as w: |
|
80 | }), warnings.catch_warnings(record=True) as w: | |
81 | ipdir = paths.get_ipython_dir() |
|
81 | ipdir = paths.get_ipython_dir() | |
82 |
|
82 | |||
83 |
assert ipdir == os.path.join(tmphome.name, " |
|
83 | assert ipdir == os.path.join(tmphome.name, XDG_TEST_DIR, "ipython") | |
84 | if sys.platform != 'darwin': |
|
84 | assert len(w) == 0 | |
85 | assert len(w) == 1 |
|
|||
86 | assert "Moving" in str(w[0]) |
|
|||
87 | finally: |
|
85 | finally: | |
88 | tmphome.cleanup() |
|
86 | tmphome.cleanup() | |
89 |
|
87 | |||
@@ -105,10 +103,8 b' def test_get_ipython_dir_4():' | |||||
105 | }), warnings.catch_warnings(record=True) as w: |
|
103 | }), warnings.catch_warnings(record=True) as w: | |
106 | ipdir = paths.get_ipython_dir() |
|
104 | ipdir = paths.get_ipython_dir() | |
107 |
|
105 | |||
108 | assert ipdir == os.path.join(HOME_TEST_DIR, ".ipython") |
|
106 | assert len(w) == 1 | |
109 | if sys.platform != 'darwin': |
|
107 | assert "Ignoring" in str(w[0]) | |
110 | assert len(w) == 1 |
|
|||
111 | assert "Ignoring" in str(w[0]) |
|
|||
112 |
|
108 | |||
113 |
|
109 | |||
114 | def test_get_ipython_dir_5(): |
|
110 | def test_get_ipython_dir_5(): | |
@@ -179,7 +175,7 b' def test_get_ipython_dir_8():' | |||||
179 |
|
175 | |||
180 | def test_get_ipython_cache_dir(): |
|
176 | def test_get_ipython_cache_dir(): | |
181 | with modified_env({'HOME': HOME_TEST_DIR}): |
|
177 | with modified_env({'HOME': HOME_TEST_DIR}): | |
182 |
if os.name == |
|
178 | if os.name == "posix": | |
183 | # test default |
|
179 | # test default | |
184 | os.makedirs(os.path.join(HOME_TEST_DIR, ".cache")) |
|
180 | os.makedirs(os.path.join(HOME_TEST_DIR, ".cache")) | |
185 | with modified_env({'XDG_CACHE_HOME': None}): |
|
181 | with modified_env({'XDG_CACHE_HOME': None}): |
@@ -54,8 +54,7 b' def get_ipython_dir() -> str:' | |||||
54 | warn(('{0} is deprecated. Move link to {1} to ' |
|
54 | warn(('{0} is deprecated. Move link to {1} to ' | |
55 | 'get rid of this message').format(cu(xdg_ipdir), cu(ipdir))) |
|
55 | 'get rid of this message').format(cu(xdg_ipdir), cu(ipdir))) | |
56 | else: |
|
56 | else: | |
57 | warn('Moving {0} to {1}'.format(cu(xdg_ipdir), cu(ipdir))) |
|
57 | ipdir = xdg_ipdir | |
58 | shutil.move(xdg_ipdir, ipdir) |
|
|||
59 |
|
58 | |||
60 | ipdir = os.path.normpath(os.path.expanduser(ipdir)) |
|
59 | ipdir = os.path.normpath(os.path.expanduser(ipdir)) | |
61 |
|
60 |
@@ -205,7 +205,7 b' def get_xdg_dir():' | |||||
205 |
|
205 | |||
206 | env = os.environ |
|
206 | env = os.environ | |
207 |
|
207 | |||
208 | if os.name == 'posix' and sys.platform != 'darwin': |
|
208 | if os.name == "posix": | |
209 | # Linux, Unix, AIX, etc. |
|
209 | # Linux, Unix, AIX, etc. | |
210 | # use ~/.config if empty OR not set |
|
210 | # use ~/.config if empty OR not set | |
211 | xdg = env.get("XDG_CONFIG_HOME", None) or os.path.join(get_home_dir(), '.config') |
|
211 | xdg = env.get("XDG_CONFIG_HOME", None) or os.path.join(get_home_dir(), '.config') | |
@@ -224,7 +224,7 b' def get_xdg_cache_dir():' | |||||
224 |
|
224 | |||
225 | env = os.environ |
|
225 | env = os.environ | |
226 |
|
226 | |||
227 | if os.name == 'posix' and sys.platform != 'darwin': |
|
227 | if os.name == "posix": | |
228 | # Linux, Unix, AIX, etc. |
|
228 | # Linux, Unix, AIX, etc. | |
229 | # use ~/.cache if empty OR not set |
|
229 | # use ~/.cache if empty OR not set | |
230 | xdg = env.get("XDG_CACHE_HOME", None) or os.path.join(get_home_dir(), '.cache') |
|
230 | xdg = env.get("XDG_CACHE_HOME", None) or os.path.join(get_home_dir(), '.cache') |
@@ -238,11 +238,11 b' def test_get_xdg_dir_2():' | |||||
238 |
|
238 | |||
239 | @with_environment |
|
239 | @with_environment | |
240 | def test_get_xdg_dir_3(): |
|
240 | def test_get_xdg_dir_3(): | |
241 |
"""test_get_xdg_dir_3, check xdg_dir not used on |
|
241 | """test_get_xdg_dir_3, check xdg_dir not used on non-posix systems""" | |
242 | reload(path) |
|
242 | reload(path) | |
243 | path.get_home_dir = lambda : HOME_TEST_DIR |
|
243 | path.get_home_dir = lambda : HOME_TEST_DIR | |
244 |
os.name = " |
|
244 | os.name = "nt" | |
245 |
sys.platform = " |
|
245 | sys.platform = "win32" | |
246 | env.pop('IPYTHON_DIR', None) |
|
246 | env.pop('IPYTHON_DIR', None) | |
247 | env.pop('IPYTHONDIR', None) |
|
247 | env.pop('IPYTHONDIR', None) | |
248 | env.pop('XDG_CONFIG_HOME', None) |
|
248 | env.pop('XDG_CONFIG_HOME', None) |
General Comments 0
You need to be logged in to leave comments.
Login now