/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/test_osutils.py

  • Committer: Martin
  • Date: 2019-06-16 01:03:51 UTC
  • mto: This revision was merged to the branch mainline in revision 7340.
  • Revision ID: gzlist@googlemail.com-20190616010351-uz89ydnwdoal4ve4
Split non-ini config methods to bedding

Functions that determine filesystem paths to use for config and default
username are now outside of the main (large) config module.

Also move cache_dir function from osutils and normalise logic.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2344
2344
            pywintypes.error(errno.EINVAL, "Invalid parameter", "Caller")))
2345
2345
 
2346
2346
 
2347
 
class TestXDGCacheDir(tests.TestCaseInTempDir):
2348
 
    # must be in temp dir because tests for the existence of the breezy
2349
 
    # subdirectory of $XDG_CACHE_HOME
2350
 
 
2351
 
    def setUp(self):
2352
 
        super(TestXDGCacheDir, self).setUp()
2353
 
        if sys.platform in ('darwin', 'win32'):
2354
 
            raise tests.TestNotApplicable(
2355
 
                'XDG cache dir not used on this platform')
2356
 
        self.overrideEnv('HOME', self.test_home_dir)
2357
 
        # BZR_HOME overrides everything we want to test so unset it.
2358
 
        self.overrideEnv('BZR_HOME', None)
2359
 
 
2360
 
    def test_xdg_cache_dir_exists(self):
2361
 
        """When ~/.cache/breezy exists, use it as the cache dir."""
2362
 
        cachedir = osutils.pathjoin(self.test_home_dir, '.cache')
2363
 
        newdir = osutils.pathjoin(cachedir, 'breezy')
2364
 
        try:
2365
 
            from xdg import BaseDirectory
2366
 
        except ImportError:
2367
 
            pass
2368
 
        else:
2369
 
            self.overrideAttr(BaseDirectory, "xdg_cache_home", cachedir)
2370
 
        os.makedirs(newdir)
2371
 
        self.assertEqual(osutils.cache_dir(), newdir)
2372
 
 
2373
 
    def test_xdg_cache_home_unix(self):
2374
 
        """When XDG_CACHE_HOME is set, use it."""
2375
 
        if sys.platform in ('nt', 'win32'):
2376
 
            raise tests.TestNotApplicable(
2377
 
                'XDG cache dir not used on this platform')
2378
 
        xdgcachedir = osutils.pathjoin(self.test_home_dir, 'xdgcache')
2379
 
        self.overrideEnv('XDG_CACHE_HOME', xdgcachedir)
2380
 
        try:
2381
 
            from xdg import BaseDirectory
2382
 
        except ImportError:
2383
 
            pass
2384
 
        else:
2385
 
            self.overrideAttr(BaseDirectory, "xdg_cache_home", xdgcachedir)
2386
 
        newdir = osutils.pathjoin(xdgcachedir, 'breezy')
2387
 
        os.makedirs(newdir)
2388
 
        self.assertEqual(osutils.cache_dir(), newdir)
2389
 
 
2390
2347
class SupportsExecutableTests(tests.TestCaseInTempDir):
2391
2348
 
2392
2349
    def test_returns_bool(self):