~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/blackbox.py

  • Committer: Martin Pool
  • Date: 2005-09-02 02:06:23 UTC
  • Revision ID: mbp@sourcefrog.net-20050902020623-40a3a7b183da2b12
- make 0.0.7 release

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
"""
28
28
 
29
29
import sys
 
30
 
30
31
from bzrlib.selftest import TestCaseInTempDir, BzrTestBase
 
32
from bzrlib.branch import Branch
 
33
from bzrlib.commands import run_bzr
 
34
 
31
35
 
32
36
class ExternalBase(TestCaseInTempDir):
33
 
 
34
37
    def runbzr(self, args, retcode=0,backtick=False):
35
 
        try:
36
 
            import shutil
37
 
            from subprocess import call
38
 
        except ImportError, e:
39
 
            _need_subprocess()
40
 
            raise
41
 
 
42
38
        if isinstance(args, basestring):
43
39
            args = args.split()
44
40
 
49
45
            return self.runcmd(['python', self.BZRPATH,] + args,
50
46
                           retcode=retcode)
51
47
 
 
48
 
52
49
class TestCommands(ExternalBase):
53
50
 
54
51
    def test_help_commands(self):
59
56
        self.runbzr('commit -h')
60
57
 
61
58
    def test_init_branch(self):
62
 
        import os
63
59
        self.runbzr(['init'])
64
60
 
65
61
    def test_whoami(self):
198
194
 
199
195
    def test_merge(self):
200
196
        from bzrlib.branch import Branch
201
 
        from bzrlib.commands import run_bzr
202
197
        import os
203
198
        
204
199
        os.mkdir('a')
224
219
        a.get_revision_xml(b.last_patch())
225
220
 
226
221
        self.log('pending merges: %s', a.pending_merges())
227
 
#        assert a.pending_merges() == [b.last_patch()], "Assertion %s %s" \
228
 
#        % (a.pending_merges(), b.last_patch())
 
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
 
229
246
 
230
247
class OldTests(ExternalBase):
231
248
    """old tests moved from ./testbzr."""