~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_sftp_transport.py

  • Committer: John Arbash Meinel
  • Date: 2006-07-31 23:04:57 UTC
  • mto: This revision was merged to the branch mainline in revision 1902.
  • Revision ID: john@arbash-meinel.com-20060731230457-5e8f5a064959d474
Update tests to use a truly unused port

Show diffs side-by-side

added added

removed removed

Lines of Context:
293
293
 
294
294
        self._transport_sftp = bzrlib.transport.sftp
295
295
 
296
 
        self.bogus_url = 'sftp://127.0.0.1:1/'
 
296
        # open a random port, so we know nobody else is using it
 
297
        # but don't actually listen on the port.
 
298
        s = socket.socket()
 
299
        s.bind(('localhost', 0))
 
300
        self.bogus_url = 'sftp://%s:%s/' % s.getsockname()
297
301
 
298
302
        orig_vendor = bzrlib.transport.sftp._ssh_vendor
299
 
        def reset_vendor():
 
303
        def reset():
300
304
            bzrlib.transport.sftp._ssh_vendor = orig_vendor
301
 
        self.addCleanup(reset_vendor)
 
305
            s.close()
 
306
        self.addCleanup(reset)
302
307
 
303
308
    def set_vendor(self, vendor):
304
309
        self._transport_sftp._ssh_vendor = vendor