~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_config.py

  • Committer: Andrew Bennetts
  • Date: 2010-12-14 23:14:44 UTC
  • mfrom: (5569 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5570.
  • Revision ID: andrew.bennetts@canonical.com-20101214231444-uubf7zjbg8q92ocs
MergeĀ lp:bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
432
432
            '/home/bogus/.cache')
433
433
 
434
434
 
 
435
class TestXDGConfigDir(tests.TestCaseInTempDir):
 
436
    # must be in temp dir because config tests for the existence of the bazaar
 
437
    # subdirectory of $XDG_CONFIG_HOME
 
438
 
 
439
    def setUp(self):
 
440
        if sys.platform in ('darwin', 'win32'):
 
441
            raise tests.TestNotApplicable(
 
442
                'XDG config dir not used on this platform')
 
443
        super(TestXDGConfigDir, self).setUp()
 
444
        os.environ['HOME'] = self.test_home_dir
 
445
        # BZR_HOME overrides everything we want to test so unset it.
 
446
        del os.environ['BZR_HOME']
 
447
 
 
448
    def test_xdg_config_dir_exists(self):
 
449
        """When ~/.config/bazaar exists, use it as the config dir."""
 
450
        newdir = osutils.pathjoin(self.test_home_dir, '.config', 'bazaar')
 
451
        os.makedirs(newdir)
 
452
        self.assertEqual(config.config_dir(), newdir)
 
453
 
 
454
    def test_xdg_config_home(self):
 
455
        """When XDG_CONFIG_HOME is set, use it."""
 
456
        xdgconfigdir = osutils.pathjoin(self.test_home_dir, 'xdgconfig')
 
457
        os.environ['XDG_CONFIG_HOME'] = xdgconfigdir
 
458
        newdir = osutils.pathjoin(xdgconfigdir, 'bazaar')
 
459
        os.makedirs(newdir)
 
460
        self.assertEqual(config.config_dir(), newdir)
 
461
 
 
462
 
435
463
class TestIniConfig(tests.TestCaseInTempDir):
436
464
 
437
465
    def make_config_parser(self, s):