Rev 5960: (vila) Support pyftplib-0.6.0 as an ftp test server (Vincent Ladeuil) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Tue Jun 7 13:49:15 UTC 2011
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5960 [merge]
revision-id: pqm at pqm.ubuntu.com-20110607134912-0icu0bcbn5ss4mod
parent: pqm at pqm.ubuntu.com-20110607123019-k0y8xn80h16a1u8o
parent: v.ladeuil+lp at free.fr-20110607082021-4wt3mlh9mqsn0djg
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2011-06-07 13:49:12 +0000
message:
(vila) Support pyftplib-0.6.0 as an ftp test server (Vincent Ladeuil)
modified:
bzrlib/tests/ftp_server/__init__.py __init__.py-20090227130107-4gcpgvr00l7v3fsw-1
bzrlib/tests/ftp_server/pyftpdlib_based.py pyftpdlib_based.py-20090227151014-882k9q34m1gwnhvi-1
doc/en/release-notes/bzr-2.4.txt bzr2.4.txt-20110114053217-k7ym9jfz243fddjm-1
=== modified file 'bzrlib/tests/ftp_server/__init__.py'
--- a/bzrlib/tests/ftp_server/__init__.py 2011-05-11 11:35:28 +0000
+++ b/bzrlib/tests/ftp_server/__init__.py 2011-06-07 07:05:46 +0000
@@ -17,10 +17,25 @@
Facilities to use ftp test servers.
"""
+import sys
+
from bzrlib import tests
try:
+ from bzrlib.tests.ftp_server import medusa_based
+ # medusa is bogus starting with python2.6, since we don't support earlier
+ # pythons anymore, it's currently useless. There is hope though that the
+ # unicode bugs get fixed in the future so we leave it disabled until
+ # then. Keeping the framework in place means that only the following line
+ # will need to be changed. The last tests were conducted with medusa-2.0
+ # -- vila 20110607
+ medusa_available = False
+except ImportError:
+ medusa_available = False
+
+
+try:
from bzrlib.tests.ftp_server import pyftpdlib_based
pyftpdlib_available = True
except ImportError:
@@ -38,7 +53,7 @@
"""
def _probe(self):
- return pyftpdlib_available
+ return medusa_available or pyftpdlib_available
def feature_name(self):
return 'FTPServer'
@@ -69,7 +84,9 @@
raise tests.UnavailableFeature(FTPServerFeature)
-if pyftpdlib_available:
+if medusa_available:
+ FTPTestServer = medusa_based.FTPTestServer
+elif pyftpdlib_available:
FTPTestServer = pyftpdlib_based.FTPTestServer
else:
FTPTestServer = UnavailableFTPTestServer
=== modified file 'bzrlib/tests/ftp_server/pyftpdlib_based.py'
--- a/bzrlib/tests/ftp_server/pyftpdlib_based.py 2010-06-30 15:19:36 +0000
+++ b/bzrlib/tests/ftp_server/pyftpdlib_based.py 2011-06-07 07:00:23 +0000
@@ -34,6 +34,11 @@
from bzrlib.tests import test_server
+# Convert the pyftplib string version into a tuple to avoid traps in string
+# comparison.
+pyftplib_version = tuple(map(int, ftpserver.__ver__.split('.')))
+
+
class AnonymousWithWriteAccessAuthorizer(ftpserver.DummyAuthorizer):
def _check_permissions(self, username, perm):
@@ -113,16 +118,34 @@
self.log('OK SITE CHMOD 0%03o "%s".' % (mode, ftp_path))
self.respond('200 SITE CHMOD succesful.')
-
-# pyftpdlib says to define SITE commands by declaring ftp_SITE_<CMD> methods,
-# but fails to recognize them.
-ftpserver.proto_cmds['SITE CHMOD'] = ftpserver._CommandProperty(
- perm='w', # Best fit choice even if not exactly right (can be d, f or m too)
- auth_needed=True, arg_needed=True, check_path=False,
- help='Syntax: SITE CHMOD <SP> octal_mode_bits file-name (chmod file)',
- )
-# An empty password is valid, hence the arg is neither mandatory not forbidden
-ftpserver.proto_cmds['PASS'].arg_needed = None
+ if pyftplib_version >= (0, 6, 0):
+ def log_cmd(self, cmd, arg, respcode, respstr):
+ # base class version choke on unicode, the alternative is to just
+ # provide an empty implementation and relies on the client to do
+ # the logging for debugging purposes. Not worth the trouble so far
+ # -- vila 20110607
+ if cmd in ("DELE", "RMD", "RNFR", "RNTO", "MKD"):
+ line = '"%s" %s' % (' '.join([cmd, unicode(arg)]).strip(),
+ respcode)
+ self.log(line)
+
+
+if pyftplib_version < (0, 6,0):
+ # pyftpdlib says to define SITE commands by declaring ftp_SITE_<CMD>
+ # methods, but fails to recognize them.
+ ftpserver.proto_cmds['SITE CHMOD'] = ftpserver._CommandProperty(
+ # Best fit choice even if not exactly right (can be d, f or m too)
+ perm='w',
+ auth_needed=True, arg_needed=True, check_path=False,
+ help='Syntax: SITE CHMOD <SP> octal_mode_bits file-name (chmod file)',
+ )
+ # An empty password is valid, hence the arg is neither mandatory not
+ # forbidden
+ ftpserver.proto_cmds['PASS'].arg_needed = None
+else:
+ # Same rationale as above (the password should be optional), but the hole
+ # in pyftplib-0.6.0 is narrower
+ ftpserver.proto_cmds['PASS']['arg'] = None
class ftp_server(ftpserver.FTPServer):
=== modified file 'doc/en/release-notes/bzr-2.4.txt'
--- a/doc/en/release-notes/bzr-2.4.txt 2011-06-06 11:13:41 +0000
+++ b/doc/en/release-notes/bzr-2.4.txt 2011-06-07 08:20:21 +0000
@@ -117,6 +117,11 @@
* Multiple ``selftest --exclude`` options are now combined instead of
overriding each other. (Vincent Ladeuil, #746991)
+* Restore some ``FTPTransport`` test coverage by allowing ``pyftpdlib
+ 0.6.0`` to be used. Also restore ``medusa`` support while leaving it
+ disabled to make it easier to use if/when we can in the future.
+ (Vincent Ladeuil, #781140)
+
* `TestImportTariffs` no longer uses the real ``$HOME``. This prevents it
from polluting ``$HOME/.bzr.log`` or being accidentally influenced by
user configuration such as aliases. It still runs with all the user's
More information about the bazaar-commits
mailing list