~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/whitebox.py

  • Committer: Martin Pool
  • Date: 2005-08-12 15:41:44 UTC
  • Revision ID: mbp@sourcefrog.net-20050812154144-bc98570a78b8f633
- merge in deferred revfile work

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
import os
4
4
import unittest
5
5
 
6
 
from bzrlib.selftest import InTempDir, TestCase
 
6
from bzrlib.selftest import InTempDir, TestBase
7
7
from bzrlib.branch import ScratchBranch, Branch
8
8
from bzrlib.errors import NotBranchError, NotVersionedError
9
9
 
10
10
 
11
 
class TestBranch(InTempDir):
12
 
 
13
 
    def test_unknowns(self):
 
11
class Unknowns(InTempDir):
 
12
    def runTest(self):
14
13
        b = Branch('.', init=True)
15
14
 
16
15
        self.build_tree(['hello.txt',
19
18
        self.assertEquals(list(b.unknowns()),
20
19
                          ['hello.txt'])
21
20
 
22
 
    def test_no_changes(self):
 
21
 
 
22
 
 
23
class NoChanges(InTempDir):
 
24
    def runTest(self):
23
25
        from bzrlib.errors import PointlessCommit
24
26
        
25
27
        b = Branch('.', init=True)
53
55
        
54
56
 
55
57
 
56
 
class TestRevisionId(TestCase):
57
 
    
58
 
    def test_validate_revision_id(self):
 
58
class ValidateRevisionId(TestBase):
 
59
    def runTest(self):
59
60
        from bzrlib.revision import validate_revision_id
60
61
        validate_revision_id('mbp@sourcefrog.net-20050311061123-96a255005c7c9dbe')
 
62
        
61
63
        self.assertRaises(ValueError,
62
64
                          validate_revision_id,
63
65
                          ' asdkjas')
 
66
 
 
67
 
64
68
        self.assertRaises(ValueError,
65
69
                          validate_revision_id,
66
70
                          'mbp@sourcefrog.net-20050311061123-96a255005c7c9dbe\n')
 
71
 
 
72
 
67
73
        self.assertRaises(ValueError,
68
74
                          validate_revision_id,
69
75
                          ' mbp@sourcefrog.net-20050311061123-96a255005c7c9dbe')
 
76
 
70
77
        self.assertRaises(ValueError,
71
78
                          validate_revision_id,
72
79
                          'Martin Pool <mbp@sourcefrog.net>-20050311061123-96a255005c7c9dbe')
73
80
 
74
81
 
 
82
 
75
83
class PendingMerges(InTempDir):
76
 
    def test_pending_merges(self):
77
 
        """Tracking pending-merged revisions."""
 
84
    """Tracking pending-merged revisions."""
 
85
    def runTest(self):
78
86
        b = Branch('.', init=True)
79
87
 
80
88
        self.assertEquals(b.pending_merges(), [])
104
112
        # list should be cleared when we do a commit
105
113
        self.assertEquals(b.pending_merges(), [])
106
114
        
107
 
    def test_revert(self):
108
 
        """Test selected-file revert"""
 
115
        
 
116
        
 
117
 
 
118
class Revert(InTempDir):
 
119
    """Test selected-file revert"""
 
120
    def runTest(self):
109
121
        b = Branch('.', init=True)
110
122
 
111
123
        self.build_tree(['hello.txt'])
131
143
        self.check_file_contents('hello.txt', 'initial hello')
132
144
        self.check_file_contents('hello.txt~', 'initial hello')
133
145
 
134
 
    def test_rename_dirs(self):
135
 
        """Test renaming directories and the files within them."""
 
146
 
 
147
 
 
148
class RenameDirs(InTempDir):
 
149
    """Test renaming directories and the files within them."""
 
150
    def runTest(self):
136
151
        b = Branch('.', init=True)
137
152
        self.build_tree(['dir/', 'dir/sub/', 'dir/sub/file'])
138
153
        b.add(['dir', 'dir/sub', 'dir/sub/file'])
161
176
                                   ['newdir', 'newdir/newsub',
162
177
                                    'newdir/newsub/file'])
163
178
 
164
 
    def test_relpath(self):
165
 
        """test for branch path lookups
166
 
    
167
 
        Branch.relpath and bzrlib.branch._relpath do a simple but subtle
168
 
        job: given a path (either relative to cwd or absolute), work out
169
 
        if it is inside a branch and return the path relative to the base.
170
 
        """
 
179
        
 
180
 
 
181
 
 
182
class BranchPathTestCase(TestBase):
 
183
    """test for branch path lookups
 
184
 
 
185
    Branch.relpath and bzrlib.branch._relpath do a simple but subtle
 
186
    job: given a path (either relative to cwd or absolute), work out
 
187
    if it is inside a branch and return the path relative to the base.
 
188
    """
 
189
 
 
190
    def runTest(self):
171
191
        from bzrlib.branch import _relpath
172
192
        import tempfile, shutil
173
193
        
220
240
            shutil.rmtree(dtmp)
221
241
 
222
242
 
223
 
TEST_CLASSES = [TestBranch,
224
 
                TestRevisionId,
225
 
                PendingMerges
 
243
 
 
244
 
 
245
TEST_CLASSES = [Unknowns,
 
246
                ValidateRevisionId,
 
247
                PendingMerges,
 
248
                Revert,
 
249
                RenameDirs,
 
250
                BranchPathTestCase,
226
251
                ]