/brz/remove-bazaar

To get this branch, use:
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
                          )
25
26
27
class TestOptions(TestCase):
28
29
    current_test = None
30
31
    def test_transport_set_to_sftp(self):
32
        # test the --transport option has taken effect from within the
33
        # test_transport test
1551.2.47 by abentley
Fixed test_selftest's use of sftp
34
        try:
35
            import bzrlib.transport.sftp
36
        except ParamikoNotPresent:
37
            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.
38
        if TestOptions.current_test != "test_transport_set_to_sftp":
39
            return
40
        self.assertEqual(bzrlib.transport.sftp.SFTPAbsoluteServer,
41
                         bzrlib.tests.default_transport)
42
1534.4.26 by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.
43
    def test_transport_set_to_memory(self):
44
        # test the --transport option has taken effect from within the
45
        # test_transport test
46
        import bzrlib.transport.memory
47
        if TestOptions.current_test != "test_transport_set_to_memory":
48
            return
49
        self.assertEqual(bzrlib.transport.memory.MemoryServer,
50
                         bzrlib.tests.default_transport)
51
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.
52
    def test_transport(self):
53
        # test that --transport=sftp works
1551.2.47 by abentley
Fixed test_selftest's use of sftp
54
        try:
55
            import bzrlib.transport.sftp
56
        except ParamikoNotPresent:
57
            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.
58
        old_transport = bzrlib.tests.default_transport
59
        old_root = TestCaseInTempDir.TEST_ROOT
60
        TestCaseInTempDir.TEST_ROOT = None
61
        try:
62
            TestOptions.current_test = "test_transport_set_to_sftp"
63
            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.
64
            
65
            self.assertContainsRe(stdout, 'Ran 1 test')
66
            self.assertEqual(old_transport, bzrlib.tests.default_transport)
67
68
            TestOptions.current_test = "test_transport_set_to_memory"
69
            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.
70
            self.assertContainsRe(stdout, 'Ran 1 test')
71
            self.assertEqual(old_transport, bzrlib.tests.default_transport)
72
        finally:
73
            bzrlib.tests.default_transport = old_transport
74
            TestOptions.current_test = None
75
            TestCaseInTempDir.TEST_ROOT = old_root