testing sftp under windows

Alexey Shamrin shamrin at gmail.com
Fri Nov 11 12:56:19 GMT 2005


On 11/11/05, Alexey Shamrin <shamrin at gmail.com> wrote:
> Running "bzr selftest testsftp" gives 10 failed test out of 10
> possible (see the end the message for a log). They all fail when
> calling self._socket.listen(1).
>
> Does anyone know how to fix this?

I went ahead and decided to learn a little about sockets
(http://www.amk.ca/python/howto/sockets/ was really helpful).

The problem is that under Windows socket doesn't allow invoking
"listen" without doing "bind" first. See the patch is bellow. I had to
add a call to self.get_transport() in test_delete and test_move
because they would "bind", but wouldn't "close" the socket, causing
"Address already in use" exception at the next test.

After this change "bzr selftest testsftp" gives 3 fails instead of 10
:-) Additionally, another error (in test_append) is fixable with
applying a small change from John Meinel's win32 branch:
# bzr merge -r 1373..1376 http://bzr.arbash-meinel.com/branches/bzr/win32/

There are 2 failures left -- in test_append_file and test_put_file.
There are there because of '\n' vs '\r\n' issue.


Patch
=======

=== 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',55555))
         self._socket.listen(1)
         self.port = self._socket.getsockname()[1]
         self.stop_event = threading.Event()

=== modified file 'bzrlib\\selftest\\testtransport.py'
--- bzrlib\selftest\testtransport.py
+++ bzrlib\selftest\testtransport.py
@@ -444,11 +444,11 @@

     def test_delete(self):
         # TODO: Test Transport.delete
-        pass
+        t = self.get_transport()

     def test_move(self):
         # TODO: Test Transport.move
-        pass
+        t = self.get_transport()


  class LocalTransportTest(TestCaseInTempDir, TestTransportMixIn):


--
Alexey
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testsftp.log
Type: application/octet-stream
Size: 20207 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20051111/4446e9e4/attachment.obj 


More information about the bazaar mailing list