~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/blackbox.py

  • Committer: Martin Pool
  • Date: 2005-08-24 00:34:21 UTC
  • Revision ID: mbp@sourcefrog.net-20050824003421-33dd8e5c739cad2a
- send trace messages out through python logging module

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
 
34
34
 
35
35
class ExternalBase(InTempDir):
36
 
    def runbzr(self, args, retcode=0):
 
36
    def runbzr(self, args, retcode=0,backtick=False):
37
37
        try:
38
38
            import shutil
39
39
            from subprocess import call
43
43
 
44
44
        if isinstance(args, basestring):
45
45
            args = args.split()
46
 
            
47
 
        return self.runcmd(['python', self.BZRPATH,] + args,
 
46
 
 
47
        if backtick:
 
48
            return self.backtick(['python', self.BZRPATH,] + args,
 
49
                           retcode=retcode)
 
50
        else:
 
51
            return self.runcmd(['python', self.BZRPATH,] + args,
48
52
                           retcode=retcode)
49
53
 
50
54
 
121
125
        # this should always identify something, if only "john@localhost"
122
126
        self.runbzr("whoami")
123
127
        self.runbzr("whoami --email")
124
 
        self.assertEquals(self.backtick("bzr whoami --email").count('@'),
125
 
                          1)
 
128
 
 
129
        self.assertEquals(self.runbzr("whoami --email",
 
130
                                      backtick=True).count('@'), 1)
 
131
        
 
132
class UserIdentityBranch(ExternalBase):
 
133
    def runTest(self):
 
134
        # tests branch specific user identity
 
135
        self.runbzr('init')
 
136
        f = file('.bzr/email', 'wt')
 
137
        f.write('Branch Identity <branch@identi.ty>')
 
138
        f.close()
 
139
        whoami = self.runbzr("whoami",backtick=True)
 
140
        whoami_email = self.runbzr("whoami --email",backtick=True)
 
141
        self.assertTrue(whoami.startswith('Branch Identity <branch@identi.ty>'))
 
142
        self.assertTrue(whoami_email.startswith('branch@identi.ty'))
126
143
 
127
144
 
128
145
class InvalidCommands(ExternalBase):
356
373
 
357
374
class RevertCommand(ExternalBase):
358
375
    def runTest(self):
 
376
        import os
359
377
        self.runbzr('init')
360
378
 
361
379
        file('hello', 'wt').write('foo')
362
380
        self.runbzr('add hello')
363
381
        self.runbzr('commit -m setup hello')
 
382
 
 
383
        file('goodbye', 'wt').write('baz')
 
384
        self.runbzr('add goodbye')
 
385
        self.runbzr('commit -m setup goodbye')
364
386
        
365
387
        file('hello', 'wt').write('bar')
 
388
        file('goodbye', 'wt').write('qux')
366
389
        self.runbzr('revert hello')
367
390
        self.check_file_contents('hello', 'foo')
 
391
        self.check_file_contents('goodbye', 'qux')
 
392
        self.runbzr('revert')
 
393
        self.check_file_contents('goodbye', 'baz')
 
394
        os.mkdir('revertdir')
 
395
        self.runbzr('add revertdir')
 
396
        self.runbzr('commit -m f')
 
397
        os.rmdir('revertdir')
 
398
        self.runbzr('revert')
 
399
 
368
400