4 sys
.path
.append('../../python')
6 from rox
import basedir
8 class TestBasedir(unittest
.TestCase
):
10 os
.environ
['XDG_DATA_HOME'] = '/tmp/share'
11 os
.environ
['XDG_DATA_DIRS'] = '/tmp/share.2:/tmp/share.3'
12 os
.environ
['XDG_CONFIG_HOME'] = '/tmp/config'
13 os
.environ
['XDG_CONFIG_DIRS'] = '/tmp/config.2:/tmp/config.3'
16 def testDefaults(self
):
17 for x
in ['XDG_DATA_HOME', 'XDG_DATA_DIRS',
18 'XDG_CONFIG_HOME', 'XDG_CONFIG_DIRS']:
22 self
.assertEquals(os
.path
.expanduser('~/.config'),
23 basedir
.xdg_config_home
)
24 self
.assertEquals([basedir
.xdg_config_home
, '/etc/xdg'],
25 basedir
.xdg_config_dirs
)
27 self
.assertEquals(os
.path
.expanduser('~/.local/share'),
28 basedir
.xdg_data_home
)
29 self
.assertEquals([basedir
.xdg_data_home
,
30 '/usr/local/share', '/usr/share'],
31 basedir
.xdg_data_dirs
)
33 def testOverride(self
):
34 self
.assertEquals('/tmp/config', basedir
.xdg_config_home
)
35 self
.assertEquals([basedir
.xdg_config_home
,
36 '/tmp/config.2', '/tmp/config.3'],
37 basedir
.xdg_config_dirs
)
39 self
.assertEquals('/tmp/share', basedir
.xdg_data_home
)
40 self
.assertEquals([basedir
.xdg_data_home
,
41 '/tmp/share.2', '/tmp/share.3'],
42 basedir
.xdg_data_dirs
)
45 assert not os
.path
.isdir(basedir
.xdg_config_home
)
46 path
= basedir
.save_config_path('ROX-Lib-Test')
47 self
.assertEquals('/tmp/config/ROX-Lib-Test', path
)
48 assert os
.path
.isdir(basedir
.xdg_config_home
)
49 assert os
.path
.isdir(path
)
52 os
.rmdir(basedir
.xdg_config_home
)