~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

  • Committer: John Arbash Meinel
  • Date: 2006-10-16 01:25:46 UTC
  • mfrom: (2071 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2080.
  • Revision ID: john@arbash-meinel.com-20061016012546-d01a0740671b4d73
[merge] bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
import unittest
25
25
import warnings
26
26
 
27
 
from bzrlib import osutils
 
27
from bzrlib import osutils, memorytree
28
28
import bzrlib
29
29
from bzrlib.progress import _BaseProgressBar
30
30
from bzrlib.tests import (
31
31
                          ChrootedTestCase,
32
32
                          TestCase,
33
33
                          TestCaseInTempDir,
 
34
                          TestCaseWithMemoryTransport,
34
35
                          TestCaseWithTransport,
35
36
                          TestSkipped,
36
37
                          TestSuite,
435
436
        self.assertEqual(self.test_home_dir, os.environ['HOME'])
436
437
 
437
438
 
 
439
class TestTestCaseWithMemoryTransport(TestCaseWithMemoryTransport):
 
440
 
 
441
    def test_home_is_non_existant_dir_under_root(self):
 
442
        """The test_home_dir for TestCaseWithMemoryTransport is missing.
 
443
 
 
444
        This is because TestCaseWithMemoryTransport is for tests that do not
 
445
        need any disk resources: they should be hooked into bzrlib in such a 
 
446
        way that no global settings are being changed by the test (only a 
 
447
        few tests should need to do that), and having a missing dir as home is
 
448
        an effective way to ensure that this is the case.
 
449
        """
 
450
        self.assertEqual(self.TEST_ROOT + "/MemoryTransportMissingHomeDir",
 
451
            self.test_home_dir)
 
452
        self.assertEqual(self.test_home_dir, os.environ['HOME'])
 
453
        
 
454
    def test_cwd_is_TEST_ROOT(self):
 
455
        self.assertEqual(self.test_dir, self.TEST_ROOT)
 
456
        cwd = osutils.getcwd()
 
457
        self.assertEqual(self.test_dir, cwd)
 
458
 
 
459
    def test_make_branch_and_memory_tree(self):
 
460
        """In TestCaseWithMemoryTransport we should not make the branch on disk.
 
461
 
 
462
        This is hard to comprehensively robustly test, so we settle for making
 
463
        a branch and checking no directory was created at its relpath.
 
464
        """
 
465
        tree = self.make_branch_and_memory_tree('dir')
 
466
        self.failIfExists('dir')
 
467
        self.assertIsInstance(tree, memorytree.MemoryTree)
 
468
 
 
469
 
438
470
class TestTestCaseWithTransport(TestCaseWithTransport):
439
471
    """Tests for the convenience functions TestCaseWithTransport introduces."""
440
472
 
985
1017
        self.assertIsInstance(bzrlib.bzrdir.BzrDir.open('b')._format,
986
1018
                              bzrlib.bzrdir.BzrDirFormat6)
987
1019
 
988
 
    def test_make_branch_and_mutable_tree(self):
 
1020
    def test_make_branch_and_memory_tree(self):
989
1021
        # we should be able to get a new branch and a mutable tree from
990
1022
        # TestCaseWithTransport
991
1023
        tree = self.make_branch_and_memory_tree('a')