Show More
@@ -227,13 +227,13 b' def get_home_dir(require_writable=False):' | |||
|
227 | 227 | def get_xdg_dir(): |
|
228 | 228 | """Return the XDG_CONFIG_HOME, if it is defined and exists, else None. |
|
229 | 229 | |
|
230 |
This is only for posix (Linux,Unix, |
|
|
230 | This is only for non-OS X posix (Linux,Unix,etc.) systems. | |
|
231 | 231 | """ |
|
232 | 232 | |
|
233 | 233 | env = os.environ |
|
234 | 234 | |
|
235 | if os.name == 'posix': | |
|
236 |
# Linux, Unix, AIX, |
|
|
235 | if os.name == 'posix' and sys.platform != 'darwin': | |
|
236 | # Linux, Unix, AIX, etc. | |
|
237 | 237 | # use ~/.config if empty OR not set |
|
238 | 238 | xdg = env.get("XDG_CONFIG_HOME", None) or os.path.join(get_home_dir(), '.config') |
|
239 | 239 | if xdg and _writable_dir(xdg): |
@@ -93,7 +93,7 b' def setup_environment():' | |||
|
93 | 93 | each testfunction needs a pristine environment. |
|
94 | 94 | """ |
|
95 | 95 | global oldstuff, platformstuff |
|
96 | oldstuff = (env.copy(), os.name, path.get_home_dir, IPython.__file__, os.getcwd()) | |
|
96 | oldstuff = (env.copy(), os.name, sys.platform, path.get_home_dir, IPython.__file__, os.getcwd()) | |
|
97 | 97 | |
|
98 | 98 | if os.name == 'nt': |
|
99 | 99 | platformstuff = (wreg.OpenKey, wreg.QueryValueEx,) |
@@ -102,7 +102,7 b' def setup_environment():' | |||
|
102 | 102 | def teardown_environment(): |
|
103 | 103 | """Restore things that were remebered by the setup_environment function |
|
104 | 104 | """ |
|
105 | (oldenv, os.name, path.get_home_dir, IPython.__file__, old_wd) = oldstuff | |
|
105 | (oldenv, os.name, sys.platform, path.get_home_dir, IPython.__file__, old_wd) = oldstuff | |
|
106 | 106 | os.chdir(old_wd) |
|
107 | 107 | reload(path) |
|
108 | 108 | |
@@ -234,7 +234,11 b' def test_get_ipython_dir_3():' | |||
|
234 | 234 | env.pop('IPYTHONDIR', None) |
|
235 | 235 | env['XDG_CONFIG_HOME'] = XDG_TEST_DIR |
|
236 | 236 | ipdir = path.get_ipython_dir() |
|
237 | nt.assert_equal(ipdir, os.path.join(XDG_TEST_DIR, "ipython")) | |
|
237 | if sys.platform == "darwin": | |
|
238 | expected = os.path.join("someplace", ".ipython") | |
|
239 | else: | |
|
240 | expected = os.path.join(XDG_TEST_DIR, "ipython") | |
|
241 | nt.assert_equal(ipdir, expected) | |
|
238 | 242 | |
|
239 | 243 | @with_environment |
|
240 | 244 | def test_get_ipython_dir_4(): |
@@ -244,9 +248,12 b' def test_get_ipython_dir_4():' | |||
|
244 | 248 | env.pop('IPYTHON_DIR', None) |
|
245 | 249 | env.pop('IPYTHONDIR', None) |
|
246 | 250 | env['XDG_CONFIG_HOME'] = XDG_TEST_DIR |
|
247 | xdg_ipdir = os.path.join(XDG_TEST_DIR, "ipython") | |
|
248 | 251 | ipdir = path.get_ipython_dir() |
|
249 | nt.assert_equal(ipdir, xdg_ipdir) | |
|
252 | if sys.platform == "darwin": | |
|
253 | expected = os.path.join(HOME_TEST_DIR, ".ipython") | |
|
254 | else: | |
|
255 | expected = os.path.join(XDG_TEST_DIR, "ipython") | |
|
256 | nt.assert_equal(ipdir, expected) | |
|
250 | 257 | |
|
251 | 258 | @with_environment |
|
252 | 259 | def test_get_ipython_dir_5(): |
@@ -287,12 +294,13 b' def test_get_ipython_dir_7():' | |||
|
287 | 294 | |
|
288 | 295 | |
|
289 | 296 | @with_environment |
|
290 |
def test_get_xdg_dir_ |
|
|
291 |
"""test_get_xdg_dir_ |
|
|
297 | def test_get_xdg_dir_0(): | |
|
298 | """test_get_xdg_dir_0, check xdg_dir""" | |
|
292 | 299 | reload(path) |
|
293 | 300 | path._writable_dir = lambda path: True |
|
294 | 301 | path.get_home_dir = lambda : 'somewhere' |
|
295 | 302 | os.name = "posix" |
|
303 | sys.platform = "linux2" | |
|
296 | 304 | env.pop('IPYTHON_DIR', None) |
|
297 | 305 | env.pop('IPYTHONDIR', None) |
|
298 | 306 | env.pop('XDG_CONFIG_HOME', None) |
@@ -306,6 +314,7 b' def test_get_xdg_dir_1():' | |||
|
306 | 314 | reload(path) |
|
307 | 315 | path.get_home_dir = lambda : HOME_TEST_DIR |
|
308 | 316 | os.name = "posix" |
|
317 | sys.platform = "linux2" | |
|
309 | 318 | env.pop('IPYTHON_DIR', None) |
|
310 | 319 | env.pop('IPYTHONDIR', None) |
|
311 | 320 | env.pop('XDG_CONFIG_HOME', None) |
@@ -317,14 +326,32 b' def test_get_xdg_dir_2():' | |||
|
317 | 326 | reload(path) |
|
318 | 327 | path.get_home_dir = lambda : HOME_TEST_DIR |
|
319 | 328 | os.name = "posix" |
|
329 | sys.platform = "linux2" | |
|
320 | 330 | env.pop('IPYTHON_DIR', None) |
|
321 | 331 | env.pop('IPYTHONDIR', None) |
|
322 | 332 | env.pop('XDG_CONFIG_HOME', None) |
|
323 | 333 | cfgdir=os.path.join(path.get_home_dir(), '.config') |
|
324 |
os. |
|
|
334 | if not os.path.exists(cfgdir): | |
|
335 | os.makedirs(cfgdir) | |
|
325 | 336 | |
|
326 | 337 | nt.assert_equal(path.get_xdg_dir(), cfgdir) |
|
327 | 338 | |
|
339 | @with_environment | |
|
340 | def test_get_xdg_dir_3(): | |
|
341 | """test_get_xdg_dir_3, check xdg_dir not used on OS X""" | |
|
342 | reload(path) | |
|
343 | path.get_home_dir = lambda : HOME_TEST_DIR | |
|
344 | os.name = "posix" | |
|
345 | sys.platform = "darwin" | |
|
346 | env.pop('IPYTHON_DIR', None) | |
|
347 | env.pop('IPYTHONDIR', None) | |
|
348 | env.pop('XDG_CONFIG_HOME', None) | |
|
349 | cfgdir=os.path.join(path.get_home_dir(), '.config') | |
|
350 | if not os.path.exists(cfgdir): | |
|
351 | os.makedirs(cfgdir) | |
|
352 | ||
|
353 | nt.assert_equal(path.get_xdg_dir(), None) | |
|
354 | ||
|
328 | 355 | def test_filefind(): |
|
329 | 356 | """Various tests for filefind""" |
|
330 | 357 | f = tempfile.NamedTemporaryFile() |
General Comments 0
You need to be logged in to leave comments.
Login now