~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_sftp_transport.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-08-29 20:29:23 UTC
  • mfrom: (1711.9.8 jam-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20060829202923-fb8340be7d4adadb
(spiv) Refactor sftp vendor support

Show diffs side-by-side

added added

removed removed

Lines of Context:
271
271
        self._test_vendor = vendor
272
272
 
273
273
    def test_connection_paramiko(self):
274
 
        self.set_vendor('none')
 
274
        from bzrlib.transport import ssh
 
275
        self.set_vendor(ssh.ParamikoVendor())
275
276
        t = self.get_transport()
276
277
        self.assertEqual('foobar\n', t.get('a_file').read())
277
278
 
296
297
        if not paramiko_loaded:
297
298
            raise TestSkipped('you must have paramiko to run this test')
298
299
        super(SSHVendorBadConnection, self).setUp()
299
 
        import bzrlib.transport.sftp
300
 
 
301
 
        self._transport_sftp = bzrlib.transport.sftp
 
300
        import bzrlib.transport.ssh
302
301
 
303
302
        # open a random port, so we know nobody else is using it
304
303
        # but don't actually listen on the port.
306
305
        s.bind(('localhost', 0))
307
306
        self.bogus_url = 'sftp://%s:%s/' % s.getsockname()
308
307
 
309
 
        orig_vendor = bzrlib.transport.sftp._ssh_vendor
 
308
        orig_vendor = bzrlib.transport.ssh._ssh_vendor
310
309
        def reset():
311
 
            bzrlib.transport.sftp._ssh_vendor = orig_vendor
 
310
            bzrlib.transport.ssh._ssh_vendor = orig_vendor
312
311
            s.close()
313
312
        self.addCleanup(reset)
314
313
 
315
314
    def set_vendor(self, vendor):
316
 
        self._transport_sftp._ssh_vendor = vendor
 
315
        import bzrlib.transport.ssh
 
316
        bzrlib.transport.ssh._ssh_vendor = vendor
317
317
 
318
318
    def test_bad_connection_paramiko(self):
319
319
        """Test that a real connection attempt raises the right error"""
320
 
        self.set_vendor('none')
 
320
        from bzrlib.transport import ssh
 
321
        self.set_vendor(ssh.ParamikoVendor())
321
322
        self.assertRaises(errors.ConnectionError,
322
323
                          bzrlib.transport.get_transport, self.bogus_url)
323
324