testing sftp under windows

Alexey Shamrin shamrin at gmail.com
Mon Nov 14 07:09:38 GMT 2005


On 12/11/05, Robey Pointer <robey at lag.net> wrote:
> I made a couple of changes; can you verify that this works on
> Windows?  (patch is included below)  Tests still pass on posix with
> these changes too.
>
> I changed the listen port to 0 so it can grab any port it wants, in
> case 5555 is in use.

Oh, good! I didn't know I can pass 0 as a port number...

>
> Also I didn't like that we had to call get_transport() to make the
> test clean up correctly, so I tried having stop() (called from
> tearDown()) ensure that the socket is closed.  I think the reason
> this doesn't show up on posix is that posix sockets are closed in
> their __del__ methods.

This didn't help... After invoking a first empty test (that was
test_delete), all other tests stopped calling tearDown method of
TestCaseWithSFTPServer. I don't know the reason of this behaviour...

>
>
> === modified file 'bzrlib/selftest/testsftp.py'
> --- bzrlib/selftest/testsftp.py
> +++ bzrlib/selftest/testsftp.py
> @@ -54,6 +54,7 @@
>           threading.Thread.__init__(self)
>           self._callback = callback
>           self._socket = socket.socket()
> +        self._socket.bind(('localhost', 0))
>           self._socket.listen(1)
>           self.port = self._socket.getsockname()[1]
>           self.stop_event = threading.Event()
> @@ -66,6 +67,10 @@
>
>       def stop(self):
>           self.stop_event.set()
> +        try:
> +            self._socket.close()
> +        except:
> +            pass
>
>
> class TestCaseWithSFTPServer (TestCaseInTempDir):
>
>
>


--
Alexey




More information about the bazaar mailing list