~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_sftp_transport.py

  • Committer: Andrew Bennetts
  • Date: 2011-02-07 04:14:29 UTC
  • mfrom: (5535.4.26 fetch-all-tags-309682)
  • mto: This revision was merged to the branch mainline in revision 5648.
  • Revision ID: andrew.bennetts@canonical.com-20110207041429-3kc1blj34rvvxod9
Merge fetch-all-tags-309682.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Robey Pointer <robey@lag.net>
 
1
# Copyright (C) 2005-2011 Robey Pointer <robey@lag.net>
2
2
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
3
3
#
4
4
# This program is free software; you can redistribute it and/or modify
18
18
import os
19
19
import socket
20
20
import sys
21
 
import threading
22
21
import time
23
22
 
24
23
from bzrlib import (
30
29
    ui,
31
30
    )
32
31
from bzrlib.osutils import (
33
 
    pathjoin,
34
32
    lexists,
35
 
    set_or_unset_env,
36
33
    )
37
34
from bzrlib.tests import (
38
35
    features,
47
44
    from bzrlib.transport import sftp as _mod_sftp
48
45
    from bzrlib.tests import stub_sftp
49
46
 
50
 
from bzrlib.workingtree import WorkingTree
51
 
 
52
47
 
53
48
def set_test_transport_to_sftp(testcase):
54
49
    """A helper to set transports on test case instances."""
174
169
        """Test that if no 'ssh' is available we get builtin paramiko"""
175
170
        from bzrlib.transport import ssh
176
171
        # set '.' as the only location in the path, forcing no 'ssh' to exist
177
 
        orig_vendor = ssh._ssh_vendor_manager._cached_ssh_vendor
178
 
        orig_path = set_or_unset_env('PATH', '.')
179
 
        try:
180
 
            # No vendor defined yet, query for one
181
 
            ssh._ssh_vendor_manager.clear_cache()
182
 
            vendor = ssh._get_ssh_vendor()
183
 
            self.assertIsInstance(vendor, ssh.ParamikoVendor)
184
 
        finally:
185
 
            set_or_unset_env('PATH', orig_path)
186
 
            ssh._ssh_vendor_manager._cached_ssh_vendor = orig_vendor
 
172
        self.overrideAttr(ssh, '_ssh_vendor_manager')
 
173
        self.overrideEnv('PATH', '.')
 
174
        ssh._ssh_vendor_manager.clear_cache()
 
175
        vendor = ssh._get_ssh_vendor()
 
176
        self.assertIsInstance(vendor, ssh.ParamikoVendor)
187
177
 
188
178
    def test_abspath_root_sibling_server(self):
189
179
        server = stub_sftp.SFTPSiblingAbsoluteServer()
190
180
        server.start_server()
191
 
        try:
192
 
            transport = _mod_transport.get_transport(server.get_url())
193
 
            self.assertFalse(transport.abspath('/').endswith('/~/'))
194
 
            self.assertTrue(transport.abspath('/').endswith('/'))
195
 
            del transport
196
 
        finally:
197
 
            server.stop_server()
 
181
        self.addCleanup(server.stop_server)
 
182
 
 
183
        transport = _mod_transport.get_transport(server.get_url())
 
184
        self.assertFalse(transport.abspath('/').endswith('/~/'))
 
185
        self.assertTrue(transport.abspath('/').endswith('/'))
 
186
        del transport
198
187
 
199
188
 
200
189
class SFTPBranchTest(TestCaseWithSFTPServer):