~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: 2005-09-27 07:24:40 UTC
  • mfrom: (1185.1.41)
  • Revision ID: robertc@robertcollins.net-20050927072440-1bf4d99c3e1db5b3
pair programming worx... merge integration and weave

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.errors import ParamikoNotPresent
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
34
 
        try:
35
 
            import bzrlib.transport.sftp
36
 
        except ParamikoNotPresent:
37
 
            raise TestSkipped("Paramiko not present")
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
 
 
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
 
 
52
 
    def test_transport(self):
53
 
        # test that --transport=sftp works
54
 
        try:
55
 
            import bzrlib.transport.sftp
56
 
        except ParamikoNotPresent:
57
 
            raise TestSkipped("Paramiko not present")
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')
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')
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