/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/commands/test_cat.py

  • Committer: Robert Collins
  • Date: 2010-05-06 23:41:35 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506234135-yivbzczw1sejxnxc
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now
expected to return an object which can be used to unlock them. This reduces
duplicate code when using cleanups. The previous 'tokens's returned by
``Branch.lock_write`` and ``Repository.lock_write`` are now attributes
on the result of the lock_write. ``repository.RepositoryWriteLockResult``
and ``branch.BranchWriteLockResult`` document this. (Robert Collins)

``log._get_info_for_log_files`` now takes an add_cleanup callable.
(Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007, 2009, 2010, 2016 Canonical Ltd
 
1
# Copyright (C) 2007, 2009, 2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
16
16
 
17
17
import sys
18
18
 
19
 
from ...builtins import cmd_cat
20
 
from ...tests import (
21
 
    ui_testing,
22
 
    )
23
 
from ...tests.transport_util import TestCaseWithConnectionHookedTransport
 
19
from bzrlib.builtins import cmd_cat
 
20
from bzrlib.tests import StringIOWrapper
 
21
from bzrlib.tests.transport_util import TestCaseWithConnectionHookedTransport
24
22
 
25
23
 
26
24
class TestCat(TestCaseWithConnectionHookedTransport):
27
25
 
 
26
    def setUp(self):
 
27
        super(TestCat, self).setUp()
 
28
        # Redirect sys.stdout as this is what cat uses
 
29
        self.outf = StringIOWrapper()
 
30
        self.overrideAttr(sys, 'stdout', self.outf)
 
31
 
28
32
    def test_cat(self):
 
33
        # FIXME: sftp raises ReadError instead of NoSuchFile when probing for
 
34
        # branch/foo/.bzr/branch-format when used with the paramiko test
 
35
        # server.
 
36
        from bzrlib.tests import TestSkipped
 
37
        raise TestSkipped('SFTPTransport raises incorrect exception'
 
38
                          ' when reading from paramiko server')
29
39
        wt1 = self.make_branch_and_tree('branch')
30
 
        self.build_tree_contents([('branch/foo', b'foo')])
 
40
        self.build_tree_contents([('branch/foo', 'foo')])
31
41
        wt1.add('foo')
32
42
        wt1.commit('add foo')
33
43
 
34
44
        self.start_logging_connections()
35
45
 
36
46
        cmd = cmd_cat()
37
 
        cmd.outf = ui_testing.StringIOWithEncoding()
38
47
        cmd.run(self.get_url('branch/foo'))
39
 
        self.assertEqual(1, len(self.connections))
40
 
        self.assertEqual('foo', cmd.outf.getvalue())
 
48
        self.assertEquals(1, len(self.connections))
 
49
        self.assertEquals('foo', self.outf.getvalue())
 
50