~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/whitebox.py

  • Committer: aaron.bentley at utoronto
  • Date: 2005-08-27 04:42:41 UTC
  • mfrom: (1092.1.43)
  • mto: (1185.3.4)
  • mto: This revision was merged to the branch mainline in revision 1178.
  • Revision ID: aaron.bentley@utoronto.ca-20050827044241-23d676133b9fc981
Merge of robertc@robertcollins.net-20050826013321-52eee1f1da679ee9

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, TestBase
 
6
from bzrlib.selftest import InTempDir, TestCase
7
7
from bzrlib.branch import ScratchBranch, Branch
8
8
from bzrlib.errors import NotBranchError, NotVersionedError
9
9
 
10
10
 
11
 
class Unknowns(InTempDir):
12
 
    def runTest(self):
 
11
class TestBranch(InTempDir):
 
12
 
 
13
    def test_unknowns(self):
13
14
        b = Branch('.', init=True)
14
15
 
15
16
        self.build_tree(['hello.txt',
18
19
        self.assertEquals(list(b.unknowns()),
19
20
                          ['hello.txt'])
20
21
 
21
 
 
22
 
 
23
 
class NoChanges(InTempDir):
24
 
    def runTest(self):
 
22
    def test_no_changes(self):
25
23
        from bzrlib.errors import PointlessCommit
26
24
        
27
25
        b = Branch('.', init=True)
55
53
        
56
54
 
57
55
 
58
 
class ValidateRevisionId(TestBase):
59
 
    def runTest(self):
 
56
class TestRevisionId(TestCase):
 
57
    
 
58
    def test_validate_revision_id(self):
60
59
        from bzrlib.revision import validate_revision_id
61
60
        validate_revision_id('mbp@sourcefrog.net-20050311061123-96a255005c7c9dbe')
62
 
        
63
61
        self.assertRaises(ValueError,
64
62
                          validate_revision_id,
65
63
                          ' asdkjas')
66
 
 
67
 
 
68
64
        self.assertRaises(ValueError,
69
65
                          validate_revision_id,
70
66
                          'mbp@sourcefrog.net-20050311061123-96a255005c7c9dbe\n')
71
 
 
72
 
 
73
67
        self.assertRaises(ValueError,
74
68
                          validate_revision_id,
75
69
                          ' mbp@sourcefrog.net-20050311061123-96a255005c7c9dbe')
76
 
 
77
70
        self.assertRaises(ValueError,
78
71
                          validate_revision_id,
79
72
                          'Martin Pool <mbp@sourcefrog.net>-20050311061123-96a255005c7c9dbe')
80
73
 
81
74
 
82
 
 
83
75
class PendingMerges(InTempDir):
84
 
    """Tracking pending-merged revisions."""
85
 
    def runTest(self):
 
76
 
 
77
    def test_pending_merges(self):
 
78
        """Tracking pending-merged revisions."""
86
79
        b = Branch('.', init=True)
87
80
 
88
81
        self.assertEquals(b.pending_merges(), [])
89
 
        
90
 
        b.add_pending_merge('foo@azkhazan-123123-abcabc')
91
 
        
92
 
        self.assertEquals(b.pending_merges(), ['foo@azkhazan-123123-abcabc'])
93
 
    
94
 
        b.add_pending_merge('foo@azkhazan-123123-abcabc')
95
 
        
96
 
        self.assertEquals(b.pending_merges(), ['foo@azkhazan-123123-abcabc'])
97
 
 
 
82
        b.add_pending_merge('foo@azkhazan-123123-abcabc')
 
83
        self.assertEquals(b.pending_merges(), ['foo@azkhazan-123123-abcabc'])
 
84
        b.add_pending_merge('foo@azkhazan-123123-abcabc')
 
85
        self.assertEquals(b.pending_merges(), ['foo@azkhazan-123123-abcabc'])
98
86
        b.add_pending_merge('wibble@fofof--20050401--1928390812')
99
87
        self.assertEquals(b.pending_merges(),
100
88
                          ['foo@azkhazan-123123-abcabc',
101
89
                           'wibble@fofof--20050401--1928390812'])
102
 
 
103
90
        b.commit("commit from base with two merges")
104
 
 
105
91
        rev = b.get_revision(b.revision_history()[0])
106
92
        self.assertEquals(len(rev.parents), 2)
107
93
        self.assertEquals(rev.parents[0].revision_id,
108
94
                          'foo@azkhazan-123123-abcabc')
109
95
        self.assertEquals(rev.parents[1].revision_id,
110
96
                           'wibble@fofof--20050401--1928390812')
111
 
 
112
97
        # list should be cleared when we do a commit
113
98
        self.assertEquals(b.pending_merges(), [])
114
99
        
115
 
        
116
 
        
117
 
 
118
 
class Revert(InTempDir):
119
 
    """Test selected-file revert"""
120
 
    def runTest(self):
 
100
    def test_revert(self):
 
101
        """Test selected-file revert"""
121
102
        b = Branch('.', init=True)
122
103
 
123
104
        self.build_tree(['hello.txt'])
143
124
        self.check_file_contents('hello.txt', 'initial hello')
144
125
        self.check_file_contents('hello.txt~', 'initial hello')
145
126
 
146
 
 
147
 
 
148
 
class RenameDirs(InTempDir):
149
 
    """Test renaming directories and the files within them."""
150
 
    def runTest(self):
 
127
    def test_rename_dirs(self):
 
128
        """Test renaming directories and the files within them."""
151
129
        b = Branch('.', init=True)
152
130
        self.build_tree(['dir/', 'dir/sub/', 'dir/sub/file'])
153
131
        b.add(['dir', 'dir/sub', 'dir/sub/file'])
176
154
                                   ['newdir', 'newdir/newsub',
177
155
                                    'newdir/newsub/file'])
178
156
 
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):
 
157
    def test_relpath(self):
 
158
        """test for branch path lookups
 
159
    
 
160
        Branch.relpath and bzrlib.branch._relpath do a simple but subtle
 
161
        job: given a path (either relative to cwd or absolute), work out
 
162
        if it is inside a branch and return the path relative to the base.
 
163
        """
191
164
        from bzrlib.branch import _relpath
192
165
        import tempfile, shutil
193
166
        
238
211
        finally:
239
212
            os.chdir(savedir)
240
213
            shutil.rmtree(dtmp)
241
 
 
242
 
 
243
 
 
244
 
 
245
 
TEST_CLASSES = [Unknowns,
246
 
                ValidateRevisionId,
247
 
                PendingMerges,
248
 
                Revert,
249
 
                RenameDirs,
250
 
                BranchPathTestCase,
251
 
                ]