~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

  • Committer: Martin Pool
  • Date: 2006-01-30 11:55:34 UTC
  • mfrom: (1185.62.24 bzr-jam-pending)
  • Revision ID: mbp@sourcefrog.net-20060130115534-d9ca79b5856a08fa
[merge] jam-pending small fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
import os
20
20
import sys
21
21
import unittest
 
22
import warnings
22
23
 
23
24
from bzrlib.tests import (
24
25
                          _load_module_by_name,
27
28
                          TestSkipped,
28
29
                          TextTestRunner,
29
30
                          )
 
31
import bzrlib.errors as errors
30
32
 
31
33
 
32
34
class SelftestTests(TestCase):
106
108
        modules = _get_transport_modules()
107
109
        permutation_count = 0
108
110
        for module in modules:
109
 
            permutation_count += len(reduce(getattr, 
110
 
                (module + ".get_test_permutations").split('.')[1:],
111
 
                 __import__(module))())
 
111
            try:
 
112
                permutation_count += len(reduce(getattr, 
 
113
                    (module + ".get_test_permutations").split('.')[1:],
 
114
                     __import__(module))())
 
115
            except errors.DependencyNotPresent:
 
116
                pass
112
117
        input_test = TestTransportProviderAdapter(
113
118
            "test_adapter_sets_transport_class")
114
119
        adapter = TransportTestProviderAdapter()
127
132
                                            LocalAbspathServer,
128
133
                                            LocalURLServer
129
134
                                            )
130
 
        from bzrlib.transport.sftp import (SFTPTransport,
131
 
                                           SFTPAbsoluteServer,
132
 
                                           SFTPHomeDirServer,
133
 
                                           SFTPSiblingAbsoluteServer,
134
 
                                           )
 
135
        try:
 
136
            from bzrlib.transport.sftp import (SFTPTransport,
 
137
                                               SFTPAbsoluteServer,
 
138
                                               SFTPHomeDirServer,
 
139
                                               SFTPSiblingAbsoluteServer,
 
140
                                               )
 
141
        except errors.ParamikoNotPresent, e:
 
142
            warnings.warn(str(e))
 
143
            has_paramiko = False
 
144
        else:
 
145
            has_paramiko = True
135
146
        from bzrlib.transport.http import (HttpTransport,
136
147
                                           HttpServer
137
148
                                           )
162
173
        local_abspath_test = test_iter.next()
163
174
        local_urlpath_test = test_iter.next()
164
175
        memory_test = test_iter.next()
165
 
        sftp_abs_test = test_iter.next()
166
 
        sftp_homedir_test = test_iter.next()
167
 
        sftp_sibling_abs_test = test_iter.next()
 
176
        if has_paramiko:
 
177
            sftp_abs_test = test_iter.next()
 
178
            sftp_homedir_test = test_iter.next()
 
179
            sftp_sibling_abs_test = test_iter.next()
168
180
        # ftp_test = test_iter.next()
169
181
        self.assertRaises(StopIteration, test_iter.next)
170
182
        self.assertEqual(LocalTransport, local_relpath_test.transport_class)
176
188
        self.assertEqual(LocalTransport, local_urlpath_test.transport_class)
177
189
        self.assertEqual(LocalURLServer, local_urlpath_test.transport_server)
178
190
 
179
 
        self.assertEqual(SFTPTransport, sftp_abs_test.transport_class)
180
 
        self.assertEqual(SFTPAbsoluteServer, sftp_abs_test.transport_server)
181
 
        self.assertEqual(SFTPTransport, sftp_homedir_test.transport_class)
182
 
        self.assertEqual(SFTPHomeDirServer, sftp_homedir_test.transport_server)
183
 
        self.assertEqual(SFTPTransport, sftp_sibling_abs_test.transport_class)
184
 
        self.assertEqual(SFTPSiblingAbsoluteServer,
185
 
                         sftp_sibling_abs_test.transport_server)
 
191
        if has_paramiko:
 
192
            self.assertEqual(SFTPTransport, sftp_abs_test.transport_class)
 
193
            self.assertEqual(SFTPAbsoluteServer, sftp_abs_test.transport_server)
 
194
            self.assertEqual(SFTPTransport, sftp_homedir_test.transport_class)
 
195
            self.assertEqual(SFTPHomeDirServer, sftp_homedir_test.transport_server)
 
196
            self.assertEqual(SFTPTransport, sftp_sibling_abs_test.transport_class)
 
197
            self.assertEqual(SFTPSiblingAbsoluteServer,
 
198
                             sftp_sibling_abs_test.transport_server)
186
199
 
187
200
        self.assertEqual(HttpTransport, http_test.transport_class)
188
201
        self.assertEqual(HttpServer, http_test.transport_server)