2485.8.10
by Vincent Ladeuil
Add test for cat and missing. |
1 |
# Copyright (C) 2007 Canonical Ltd
|
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 |
||
29 |
def restore_stdout(): |
|
30 |
sys.stdout = self._stdout_orig |
|
31 |
||
32 |
# Redirect sys.stdout as this is what cat uses
|
|
33 |
self.outf = StringIOWrapper() |
|
34 |
self._stdout_orig = sys.stdout |
|
35 |
sys.stdout = self.outf |
|
36 |
self.addCleanup(restore_stdout) |
|
37 |
||
2485.8.10
by Vincent Ladeuil
Add test for cat and missing. |
38 |
def test_cat(self): |
2485.8.59
by Vincent Ladeuil
Update from review comments. |
39 |
# FIXME: sftp raises ReadError instead of NoSuchFile when probing for
|
40 |
# branch/foo/.bzr/branch-format when used with the paramiko test
|
|
41 |
# server.
|
|
42 |
from bzrlib.tests import TestSkipped |
|
2485.8.62
by Vincent Ladeuil
From review comments, fix typos and deprecate some functions. |
43 |
raise TestSkipped('SFTPTransport raises incorrect exception' |
44 |
' when reading from paramiko server') |
|
2485.8.10
by Vincent Ladeuil
Add test for cat and missing. |
45 |
wt1 = self.make_branch_and_tree('branch') |
2485.8.59
by Vincent Ladeuil
Update from review comments. |
46 |
self.build_tree_contents([('branch/foo', 'foo')]) |
2485.8.10
by Vincent Ladeuil
Add test for cat and missing. |
47 |
wt1.add('foo') |
48 |
wt1.commit('add foo') |
|
49 |
||
2814.11.1
by Vincent Ladeuil
Renamed install_hooks to start_logging_connections (as per Martin suggestion). |
50 |
self.start_logging_connections() |
2485.8.36
by Vincent Ladeuil
Fix test suite to provide a better debugging experience. |
51 |
|
2485.8.10
by Vincent Ladeuil
Add test for cat and missing. |
52 |
cmd = cmd_cat() |
4900.1.6
by Andrew Bennetts
Fix bzrlib.test.commands.*; they need to use 'run_direct' not 'run' so that the OperationWithCleanups is used. |
53 |
cmd.run_direct(self.get_url('branch/foo')) |
2485.8.10
by Vincent Ladeuil
Add test for cat and missing. |
54 |
self.assertEquals(1, len(self.connections)) |
2485.8.11
by Vincent Ladeuil
Fix some display leaks in tests. |
55 |
self.assertEquals('foo', self.outf.getvalue()) |
2485.8.10
by Vincent Ladeuil
Add test for cat and missing. |
56 |