[MERGE] FTP test server for python2.[456]

Martin Pool mbp at canonical.com
Thu Mar 19 07:45:09 GMT 2009


Martin Pool has voted tweak.
Status is now: Conditionally approved
Comment:
+class _FTPServerFeature(tests.Feature):
+    """Some tests want an FTP Server, check if one is available.
+
+    Right now, the only way this is available is if 'medusa' is 
installed.
+    http://www.amk.ca/python/code/medusa.html
+    """

That docstring seems inconsistent with the rest of your patch...

+
+class BzrConformingFS(ftpserver.AbstractedFS):
+
+    def chmod(self, path, mode):
+        return os.chmod(path, mode)
+
+    def listdir(self, path):
+        """List the content of a directory."""
+        # FIXME: need tests with unicode paths
+        return [osutils.safe_utf8(s) for s in os.listdir(path)]
+
+    def fs2ftp(self, fspath):
+        p = ftpserver.AbstractedFS.fs2ftp(self, fspath)
+        # FIXME: need tests with unicode paths
+        return osutils.safe_utf8(p)
+
+
+class BZRConformingFTPHandler(ftpserver.FTPHandler):

Oddly inconsistent capitalization here.

+class ftp_server(ftpserver.FTPServer):
+
+    def __init__(self, address, handler, authorizer):
+        ftpserver.FTPServer.__init__(self, address, handler)
+        self.authorizer = authorizer
+        # Worth backporting upstream ?
+        self.addr = self.socket.getsockname()
+
+

There's also FtpServer in the same file; it's just too many things with 
the same name.

+        """See bzrlib.transport.Server.tearDown."""
+        # Tell the server to stop, but also close the server socket for 
tests
+        # that start the server but never initiate a connection. 
Closing the
+        # socket should be done first though, to avoid further 
connections.
+        self._ftp_server.close()
+        self._ftpd_running = False
+        self._ftpd_thread.join()
+

I wonder if this will tend to hang waiting for the server thread, but I 
guess we can deal with it if it happens.

Also it should be in NEWS.  Aside from that it's good.

For details, see: 
http://bundlebuggy.aaronbentley.com/project/bzr/request/%3Cm2hc1qoeto.fsf%40free.fr%3E
Project: Bazaar



More information about the bazaar mailing list