~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_selftest.py

  • Committer: Robert Collins
  • Date: 2006-02-13 21:52:05 UTC
  • mto: (1534.1.22 integration)
  • mto: This revision was merged to the branch mainline in revision 1554.
  • Revision ID: robertc@robertcollins.net-20060213215205-cb3bacc87092a639
Update per review comments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
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
 
 
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')
 
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')
 
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