bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
1534.4.25
by Robert Collins
Add a --transport parameter to the test suite to set the default transport to be used in the test suite. |
1 |
# Copyright (C) 2005 by 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 version 2 as published by
|
|
5 |
# the Free Software Foundation.
|
|
6 |
#
|
|
7 |
# This program is distributed in the hope that it will be useful,
|
|
8 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
9 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
10 |
# GNU General Public License for more details.
|
|
11 |
#
|
|
12 |
# You should have received a copy of the GNU General Public License
|
|
13 |
# along with this program; if not, write to the Free Software
|
|
14 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
15 |
||
16 |
"""UI tests for the test framework."""
|
|
17 |
||
18 |
import bzrlib |
|
|
1551.2.47
by abentley
Fixed test_selftest's use of sftp |
19 |
from bzrlib.errors import ParamikoNotPresent |
|
1534.4.25
by Robert Collins
Add a --transport parameter to the test suite to set the default transport to be used in the test suite. |
20 |
from bzrlib.tests import ( |
21 |
TestCase, |
|
22 |
TestCaseInTempDir, |
|
23 |
TestSkipped, |
|
24 |
)
|
|
|
1687.1.2
by Robert Collins
Add stdin parameter to run_bzr and run_bzr_captured. |
25 |
from bzrlib.tests.blackbox import ExternalBase |
|
1534.4.25
by Robert Collins
Add a --transport parameter to the test suite to set the default transport to be used in the test suite. |
26 |
|
27 |
||
28 |
class TestOptions(TestCase): |
|
29 |
||
30 |
current_test = None |
|
31 |
||
32 |
def test_transport_set_to_sftp(self): |
|
33 |
# test the --transport option has taken effect from within the
|
|
34 |
# test_transport test
|
|
|
1551.2.47
by abentley
Fixed test_selftest's use of sftp |
35 |
try: |
36 |
import bzrlib.transport.sftp |
|
37 |
except ParamikoNotPresent: |
|
38 |
raise TestSkipped("Paramiko not present") |
|
|
1534.4.25
by Robert Collins
Add a --transport parameter to the test suite to set the default transport to be used in the test suite. |
39 |
if TestOptions.current_test != "test_transport_set_to_sftp": |
40 |
return
|
|
41 |
self.assertEqual(bzrlib.transport.sftp.SFTPAbsoluteServer, |
|
42 |
bzrlib.tests.default_transport) |
|
43 |
||
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
44 |
def test_transport_set_to_memory(self): |
45 |
# test the --transport option has taken effect from within the
|
|
46 |
# test_transport test
|
|
47 |
import bzrlib.transport.memory |
|
48 |
if TestOptions.current_test != "test_transport_set_to_memory": |
|
49 |
return
|
|
50 |
self.assertEqual(bzrlib.transport.memory.MemoryServer, |
|
51 |
bzrlib.tests.default_transport) |
|
52 |
||
|
1534.4.25
by Robert Collins
Add a --transport parameter to the test suite to set the default transport to be used in the test suite. |
53 |
def test_transport(self): |
54 |
# test that --transport=sftp works
|
|
|
1551.2.47
by abentley
Fixed test_selftest's use of sftp |
55 |
try: |
56 |
import bzrlib.transport.sftp |
|
57 |
except ParamikoNotPresent: |
|
58 |
raise TestSkipped("Paramiko not present") |
|
|
1534.4.25
by Robert Collins
Add a --transport parameter to the test suite to set the default transport to be used in the test suite. |
59 |
old_transport = bzrlib.tests.default_transport |
60 |
old_root = TestCaseInTempDir.TEST_ROOT |
|
61 |
TestCaseInTempDir.TEST_ROOT = None |
|
62 |
try: |
|
63 |
TestOptions.current_test = "test_transport_set_to_sftp" |
|
64 |
stdout = self.capture('selftest --transport=sftp test_transport_set_to_sftp') |
|
|
1534.4.26
by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create. |
65 |
|
66 |
self.assertContainsRe(stdout, 'Ran 1 test') |
|
67 |
self.assertEqual(old_transport, bzrlib.tests.default_transport) |
|
68 |
||
69 |
TestOptions.current_test = "test_transport_set_to_memory" |
|
70 |
stdout = self.capture('selftest --transport=memory test_transport_set_to_memory') |
|
|
1534.4.25
by Robert Collins
Add a --transport parameter to the test suite to set the default transport to be used in the test suite. |
71 |
self.assertContainsRe(stdout, 'Ran 1 test') |
72 |
self.assertEqual(old_transport, bzrlib.tests.default_transport) |
|
73 |
finally: |
|
74 |
bzrlib.tests.default_transport = old_transport |
|
75 |
TestOptions.current_test = None |
|
76 |
TestCaseInTempDir.TEST_ROOT = old_root |
|
|
1687.1.2
by Robert Collins
Add stdin parameter to run_bzr and run_bzr_captured. |
77 |
|
78 |
||
79 |
class TestRunBzr(ExternalBase): |
|
80 |
||
81 |
def run_bzr_captured(self, argv, retcode=0, stdin=None): |
|
82 |
self.stdin = stdin |
|
83 |
||
84 |
def test_stdin(self): |
|
85 |
# test that the stdin keyword to run_bzr is passed through to
|
|
|
1687.1.15
by Robert Collins
Review comments. |
86 |
# run_bzr_captured as-is. We do this by overriding
|
87 |
# run_bzr_captured in this class, and then calling run_bzr,
|
|
88 |
# which is a convenience function for run_bzr_captured, so
|
|
89 |
# should invoke it.
|
|
|
1687.1.2
by Robert Collins
Add stdin parameter to run_bzr and run_bzr_captured. |
90 |
self.run_bzr('foo', 'bar', stdin='gam') |
91 |
self.assertEqual('gam', self.stdin) |
|
92 |
self.run_bzr('foo', 'bar', stdin='zippy') |
|
93 |
self.assertEqual('zippy', self.stdin) |
|
94 |
||
95 |
||
96 |
class TestRunBzrCaptured(ExternalBase): |
|
97 |
||
98 |
def apply_redirected(self, stdin=None, stdout=None, stderr=None, |
|
99 |
a_callable=None, *args, **kwargs): |
|
100 |
self.stdin = stdin |
|
|
1687.1.11
by Robert Collins
Teach TestCase.run_bzr_captured about the ui factories. |
101 |
self.factory_stdin = getattr(bzrlib.ui.ui_factory, "stdin", None) |
|
1687.1.2
by Robert Collins
Add stdin parameter to run_bzr and run_bzr_captured. |
102 |
return 0 |
103 |
||
104 |
def test_stdin(self): |
|
105 |
# test that the stdin keyword to run_bzr_captured is passed through to
|
|
|
1687.1.15
by Robert Collins
Review comments. |
106 |
# apply_redirected as a StringIO. We do this by overriding
|
107 |
# apply_redirected in this class, and then calling run_bzr_captured,
|
|
108 |
# which calls apply_redirected.
|
|
|
1687.1.2
by Robert Collins
Add stdin parameter to run_bzr and run_bzr_captured. |
109 |
self.run_bzr_captured(['foo', 'bar'], stdin='gam') |
110 |
self.assertEqual('gam', self.stdin.read()) |
|
|
1687.1.11
by Robert Collins
Teach TestCase.run_bzr_captured about the ui factories. |
111 |
self.assertTrue(self.stdin is self.factory_stdin) |
|
1687.1.2
by Robert Collins
Add stdin parameter to run_bzr and run_bzr_captured. |
112 |
self.run_bzr_captured(['foo', 'bar'], stdin='zippy') |
113 |
self.assertEqual('zippy', self.stdin.read()) |
|
|
1687.1.11
by Robert Collins
Teach TestCase.run_bzr_captured about the ui factories. |
114 |
self.assertTrue(self.stdin is self.factory_stdin) |