~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/blackbox.py

  • Committer: Robert Collins
  • Date: 2005-08-25 12:46:42 UTC
  • mfrom: (1116)
  • 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-20050825124642-45ed1cd74db10370
merge from mpool

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
"""
28
28
 
29
29
import sys
30
 
 
31
 
from bzrlib.selftest import TestCaseInTempDir, BzrTestBase
32
 
from bzrlib.branch import Branch
33
 
from bzrlib.commands import run_bzr
34
 
 
35
 
 
36
 
class ExternalBase(TestCaseInTempDir):
 
30
from bzrlib.selftest import InTempDir, BzrTestBase
 
31
 
 
32
 
 
33
class ExternalBase(InTempDir):
 
34
 
37
35
    def runbzr(self, args, retcode=0,backtick=False):
 
36
        try:
 
37
            import shutil
 
38
            from subprocess import call
 
39
        except ImportError, e:
 
40
            _need_subprocess()
 
41
            raise
 
42
 
38
43
        if isinstance(args, basestring):
39
44
            args = args.split()
40
45
 
45
50
            return self.runcmd(['python', self.BZRPATH,] + args,
46
51
                           retcode=retcode)
47
52
 
48
 
 
49
53
class TestCommands(ExternalBase):
50
54
 
51
55
    def test_help_commands(self):
56
60
        self.runbzr('commit -h')
57
61
 
58
62
    def test_init_branch(self):
 
63
        import os
59
64
        self.runbzr(['init'])
60
65
 
61
66
    def test_whoami(self):
195
200
    def test_merge(self):
196
201
        from bzrlib.branch import Branch
197
202
        import os
198
 
        
199
203
        os.mkdir('a')
200
204
        os.chdir('a')
201
 
 
202
205
        self.example_branch()
203
206
        os.chdir('..')
204
207
        self.runbzr('branch a b')
217
220
        a = Branch('.')
218
221
        b = Branch('../b')
219
222
        a.get_revision_xml(b.last_patch())
220
 
 
221
 
        self.log('pending merges: %s', a.pending_merges())
222
 
        #        assert a.pending_merges() == [b.last_patch()], "Assertion %s %s" \
223
 
        #        % (a.pending_merges(), b.last_patch())
224
 
 
225
 
 
226
 
    def test_add_reports(self):
227
 
        """add command prints the names of added files."""
228
 
        b = Branch('.', init=True)
229
 
        self.build_tree(['top.txt', 'dir/', 'dir/sub.txt'])
230
 
 
231
 
        from cStringIO import StringIO
232
 
        out = StringIO()
233
 
 
234
 
        ret = self.apply_redirected(None, out, None,
235
 
                                    run_bzr,
236
 
                                    ['add'])
237
 
        self.assertEquals(ret, 0)
238
 
 
239
 
        # the ordering is not defined at the moment
240
 
        results = sorted(out.getvalue().rstrip('\n').split('\n'))
241
 
        self.assertEquals(['added dir',
242
 
                           'added dir/sub.txt',
243
 
                           'added top.txt',],
244
 
                          results)
245
 
 
 
223
        print "Pending: %s" % a.pending_merges()
 
224
#        assert a.pending_merges() == [b.last_patch()], "Assertion %s %s" \
 
225
#        % (a.pending_merges(), b.last_patch())
246
226
 
247
227
class OldTests(ExternalBase):
248
228
    """old tests moved from ./testbzr."""