~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/whitebox.py

  • Committer: Robert Collins
  • Date: 2005-08-23 06:52:09 UTC
  • mto: (974.1.50) (1185.1.10) (1092.3.1)
  • mto: This revision was merged to the branch mainline in revision 1139.
  • Revision ID: robertc@robertcollins.net-20050823065209-81cd5962c401751b
move io redirection into each test case from the global runner

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
 
20
20
 
21
21
 
22
22
 
23
 
class ValidateRevisionId(TestBase):
 
23
class NoChanges(InTempDir):
 
24
    def runTest(self):
 
25
        from bzrlib.errors import PointlessCommit
 
26
        
 
27
        b = Branch('.', init=True)
 
28
 
 
29
        self.build_tree(['hello.txt'])
 
30
 
 
31
        self.assertRaises(PointlessCommit,
 
32
                          b.commit,
 
33
                          'commit without adding',
 
34
                          allow_pointless=False)
 
35
 
 
36
        b.commit('commit pointless tree',
 
37
                 allow_pointless=True)
 
38
 
 
39
        b.add('hello.txt')
 
40
        
 
41
        b.commit('commit first added file',
 
42
                 allow_pointless=False)
 
43
        
 
44
        self.assertRaises(PointlessCommit,
 
45
                          b.commit,
 
46
                          'commit after adding file',
 
47
                          allow_pointless=False)
 
48
        
 
49
        b.commit('commit pointless revision with one file',
 
50
                 allow_pointless=True)
 
51
 
 
52
        b.add_pending_merge('mbp@892739123-2005-123123')
 
53
        b.commit('commit new merge with no text changes',
 
54
                 allow_pointless=False)
 
55
        
 
56
 
 
57
 
 
58
class ValidateRevisionId(TestCase):
24
59
    def runTest(self):
25
60
        from bzrlib.revision import validate_revision_id
26
61
        validate_revision_id('mbp@sourcefrog.net-20050311061123-96a255005c7c9dbe')
144
179
        
145
180
 
146
181
 
147
 
class BranchPathTestCase(TestBase):
 
182
class BranchPathTestCase(TestCase):
148
183
    """test for branch path lookups
149
184
 
150
185
    Branch.relpath and bzrlib.branch._relpath do a simple but subtle
158
193
        
159
194
        savedir = os.getcwdu()
160
195
        dtmp = tempfile.mkdtemp()
 
196
        # On Mac OSX, /tmp actually expands to /private/tmp
 
197
        dtmp = os.path.realpath(dtmp)
161
198
 
162
199
        def rp(p):
163
200
            return _relpath(dtmp, p)
201
238
        finally:
202
239
            os.chdir(savedir)
203
240
            shutil.rmtree(dtmp)
 
241
 
 
242
 
 
243
 
 
244
 
 
245
TEST_CLASSES = [Unknowns,
 
246
                ValidateRevisionId,
 
247
                PendingMerges,
 
248
                Revert,
 
249
                RenameDirs,
 
250
                BranchPathTestCase,
 
251
                ]