~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/stub_sftp.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-02-11 04:02:41 UTC
  • mfrom: (5017.2.2 tariff)
  • Revision ID: pqm@pqm.ubuntu.com-20100211040241-w6n021dz0uus341n
(mbp) add import-tariff tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
    urlutils,
34
34
    )
35
35
from bzrlib.transport import (
 
36
    local,
 
37
    Server,
36
38
    ssh,
37
39
    )
38
 
from bzrlib.tests import test_server
39
 
 
40
40
 
41
41
class StubServer (paramiko.ServerInterface):
42
42
 
297
297
                threading.Thread(target=self._callback, args=(s,)).start()
298
298
            except socket.error, x:
299
299
                sys.excepthook(*sys.exc_info())
300
 
                trace.warning('Socket error during accept() '
301
 
                              'within unit test server thread: %r' % x)
 
300
                warning('Socket error during accept() within unit test server'
 
301
                        ' thread: %r' % x)
302
302
            except Exception, x:
303
303
                # probably a failed test; unit test thread will log the
304
304
                # failure/error
305
305
                sys.excepthook(*sys.exc_info())
306
 
                trace.warning(
307
 
                    'Exception from within unit test server thread: %r' % x)
 
306
                warning('Exception from within unit test server thread: %r' %
 
307
                        x)
308
308
 
309
309
 
310
310
class SocketDelay(object):
382
382
        return bytes_sent
383
383
 
384
384
 
385
 
class SFTPServer(test_server.TestServer):
 
385
class SFTPServer(Server):
386
386
    """Common code for SFTP server facilities."""
387
387
 
388
388
    def __init__(self, server_interface=StubServer):
436
436
        # XXX: TODO: make sftpserver back onto backing_server rather than local
437
437
        # disk.
438
438
        if not (backing_server is None or
439
 
                isinstance(backing_server, test_server.LocalURLServer)):
 
439
                isinstance(backing_server, local.LocalURLServer)):
440
440
            raise AssertionError(
441
 
                'backing_server should not be %r, because this can only serve '
442
 
                'the local current working directory.' % (backing_server,))
 
441
                "backing_server should not be %r, because this can only serve the "
 
442
                "local current working directory." % (backing_server,))
443
443
        self._original_vendor = ssh._ssh_vendor_manager._cached_ssh_vendor
444
444
        ssh._ssh_vendor_manager._cached_ssh_vendor = self._vendor
445
 
        # FIXME: the following block should certainly just be self._homedir =
446
 
        # osutils.getcwd() but that fails badly on Unix -- vila 20100224
447
445
        if sys.platform == 'win32':
448
446
            # Win32 needs to use the UNICODE api
449
 
            self._homedir = os.getcwdu()
 
447
            self._homedir = getcwd()
450
448
        else:
451
449
            # But Linux SFTP servers should just deal in bytestreams
452
450
            self._homedir = os.getcwd()