~bzr-pqm/bzr/bzr.dev

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
19
from bzrlib.tests import (
20
                          TestCase,
21
                          TestCaseInTempDir,
22
                          TestSkipped,
23
                          )
24
25
26
class TestOptions(TestCase):
27
28
    current_test = None
29
30
    def test_transport_set_to_sftp(self):
31
        # test the --transport option has taken effect from within the
32
        # test_transport test
33
        import bzrlib.transport.sftp
34
        if TestOptions.current_test != "test_transport_set_to_sftp":
35
            return
36
        self.assertEqual(bzrlib.transport.sftp.SFTPAbsoluteServer,
37
                         bzrlib.tests.default_transport)
38
1534.4.26 by Robert Collins
Move working tree initialisation out from Branch.initialize, deprecated Branch.initialize to Branch.create.
39
    def test_transport_set_to_memory(self):
40
        # test the --transport option has taken effect from within the
41
        # test_transport test
42
        import bzrlib.transport.memory
43
        if TestOptions.current_test != "test_transport_set_to_memory":
44
            return
45
        self.assertEqual(bzrlib.transport.memory.MemoryServer,
46
                         bzrlib.tests.default_transport)
47
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.
48
    def test_transport(self):
49
        # test that --transport=sftp works
50
        # FIXME RBC 20060123 this should raise TestSkipped if sftp is not
51
        # available.
52
        old_transport = bzrlib.tests.default_transport
53
        old_root = TestCaseInTempDir.TEST_ROOT
54
        TestCaseInTempDir.TEST_ROOT = None
55
        try:
56
            TestOptions.current_test = "test_transport_set_to_sftp"
57
            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.
58
            
59
            self.assertContainsRe(stdout, 'Ran 1 test')
60
            self.assertEqual(old_transport, bzrlib.tests.default_transport)
61
62
            TestOptions.current_test = "test_transport_set_to_memory"
63
            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.
64
            self.assertContainsRe(stdout, 'Ran 1 test')
65
            self.assertEqual(old_transport, bzrlib.tests.default_transport)
66
        finally:
67
            bzrlib.tests.default_transport = old_transport
68
            TestOptions.current_test = None
69
            TestCaseInTempDir.TEST_ROOT = old_root