Exemplo n.º 1
0
 def test_default_config_home(self):
     """Ensure default values work correctly."""
     self.tweak_env('XDG_CONFIG_HOME', None)
     expected = b'/blah'
     self.patch(basedir, 'default_config_home', expected)
     self.assertFalse(os.environ.get('XDG_CONFIG_HOME', False))
     self.assertEqual(basedir.get_xdg_config_home(), expected)
Exemplo n.º 2
0
 def test_default_config_home(self):
     """Ensure default values work correctly."""
     self.tweak_env('XDG_CONFIG_HOME', None)
     expected = b'/blah'
     self.patch(basedir, 'default_config_home', expected)
     self.assertFalse(os.environ.get('XDG_CONFIG_HOME', False))
     self.assertEqual(basedir.get_xdg_config_home(), expected)
Exemplo n.º 3
0
 def test_config_home(self):
     """Test that XDG_CONFIG_DIRS is handled correctly."""
     self.tweak_env('XDG_CONFIG_HOME',
                    os.path.abspath(os.path.join(os.getcwd(),
                                                 '_trial_temp',
                                                 'config')))
     self.assertEqual(os.environ['XDG_CONFIG_HOME'].encode('utf-8'),
                      basedir.get_xdg_config_home())
Exemplo n.º 4
0
 def test_config_home(self):
     """Test that XDG_CONFIG_DIRS is handled correctly."""
     self.tweak_env(
         'XDG_CONFIG_HOME',
         os.path.abspath(os.path.join(os.getcwd(), '_trial_temp',
                                      'config')))
     self.assertEqual(os.environ['XDG_CONFIG_HOME'].encode('utf-8'),
                      basedir.get_xdg_config_home())
Exemplo n.º 5
0
def get_path_prefix(standalone=False):
    """
    Returns the platform dependent path prefix.

    :param standalone: if True it will return the prefix for a standalone
                       application.
                       Otherwise, it will return the system default for
                       configuration storage.
    :type standalone: bool
    """
    config_home = get_xdg_config_home()
    if standalone:
        config_home = os.path.join(os.getcwd(), "config")

    return config_home