~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-10-04 03:41:15 UTC
  • mfrom: (1986.2.7 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20061004034115-7728b1aad33e6433
(Robert Collins) Add TestCaseWithMemoryTransport, a test class specifically for doing tests with memory transports and no disk resources.

Show diffs side-by-side

added added

removed removed

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