/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 bzrlib/tests/test_selftest.py

  • Committer: Robert Collins
  • Date: 2006-09-18 05:35:44 UTC
  • mto: (1986.4.4 test_ancestry.py)
  • mto: This revision was merged to the branch mainline in revision 2059.
  • Revision ID: robertc@robertcollins.net-20060918053544-531ddf7fd2ae877b
New test base class TestCaseWithMemoryTransport offers memory-only
testing facilities: its not suitable for tests that need to mutate disk
state, but most tests should not need that and should be converted to
TestCaseWithMemoryTransport. (Robert Collins)

Show diffs side-by-side

added added

removed removed

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