~bzr-pqm/bzr/bzr.dev

4763.2.4 by John Arbash Meinel
merge bzr.2.1 in preparation for NEWS entry.
1
# Copyright (C) 2007, 2009, 2010 Canonical Ltd
2485.8.10 by Vincent Ladeuil
Add test for cat and missing.
2
#
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
4183.7.1 by Sabin Iacob
update FSF mailing address
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2485.8.10 by Vincent Ladeuil
Add test for cat and missing.
16
2485.8.11 by Vincent Ladeuil
Fix some display leaks in tests.
17
import sys
2485.8.10 by Vincent Ladeuil
Add test for cat and missing.
18
19
from bzrlib.builtins import cmd_cat
2485.8.11 by Vincent Ladeuil
Fix some display leaks in tests.
20
from bzrlib.tests import StringIOWrapper
2485.8.59 by Vincent Ladeuil
Update from review comments.
21
from bzrlib.tests.transport_util import TestCaseWithConnectionHookedTransport
22
2485.8.10 by Vincent Ladeuil
Add test for cat and missing.
23
24
class TestCat(TestCaseWithConnectionHookedTransport):
25
2485.8.11 by Vincent Ladeuil
Fix some display leaks in tests.
26
    def setUp(self):
27
        super(TestCat, self).setUp()
28
        # Redirect sys.stdout as this is what cat uses
29
        self.outf = StringIOWrapper()
4985.1.5 by Vincent Ladeuil
Deploying the new overrideAttr facility further reduces the complexity
30
        self.overrideAttr(sys, 'stdout', self.outf)
2485.8.11 by Vincent Ladeuil
Fix some display leaks in tests.
31
2485.8.10 by Vincent Ladeuil
Add test for cat and missing.
32
    def test_cat(self):
2485.8.59 by Vincent Ladeuil
Update from review comments.
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
2485.8.62 by Vincent Ladeuil
From review comments, fix typos and deprecate some functions.
37
        raise TestSkipped('SFTPTransport raises incorrect exception'
38
                          ' when reading from paramiko server')
2485.8.10 by Vincent Ladeuil
Add test for cat and missing.
39
        wt1 = self.make_branch_and_tree('branch')
2485.8.59 by Vincent Ladeuil
Update from review comments.
40
        self.build_tree_contents([('branch/foo', 'foo')])
2485.8.10 by Vincent Ladeuil
Add test for cat and missing.
41
        wt1.add('foo')
42
        wt1.commit('add foo')
43
2814.11.1 by Vincent Ladeuil
Renamed install_hooks to start_logging_connections (as per Martin suggestion).
44
        self.start_logging_connections()
2485.8.36 by Vincent Ladeuil
Fix test suite to provide a better debugging experience.
45
2485.8.10 by Vincent Ladeuil
Add test for cat and missing.
46
        cmd = cmd_cat()
5141.2.1 by Robert Collins
``bzrlib.commands.Command.run_direct`` is no longer needed - the pre
47
        cmd.run(self.get_url('branch/foo'))
2485.8.10 by Vincent Ladeuil
Add test for cat and missing.
48
        self.assertEquals(1, len(self.connections))
2485.8.11 by Vincent Ladeuil
Fix some display leaks in tests.
49
        self.assertEquals('foo', self.outf.getvalue())
2485.8.10 by Vincent Ladeuil
Add test for cat and missing.
50