1
# Copyright (C) 2009 Canonical Ltd
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
Facilities to use ftp test servers.
22
from bzrlib import tests
26
from bzrlib.tests.ftp_server import medusa_based
27
# medusa is bogus under python2.6
28
medusa_available = sys.version_info < (2, 6)
30
medusa_available = False
34
from bzrlib.tests.ftp_server import pyftpdlib_based
35
pyftpdlib_available = True
37
pyftpdlib_available = False
40
class _FTPServerFeature(tests.Feature):
41
"""Some tests want an FTP Server, check if one is available.
43
Right now, the only way this is available is if one of the following is
46
- 'medusa': http://www.amk.ca/python/code/medusa.html
47
- 'pyftpdlib': http://code.google.com/p/pyftpdlib/
51
return medusa_available or pyftpdlib_available
53
def feature_name(self):
57
FTPServerFeature = _FTPServerFeature()
60
class UnavailableFTPTestServer(object):
61
"""Dummy ftp test server.
63
This allows the test suite report the number of tests needing that
64
feature. We raise UnavailableFeature from methods before the test server is
65
being used. Doing so in the setUp method has bad side-effects (tearDown is
69
def setUp(self, vfs_server=None):
76
raise tests.UnavailableFeature(FTPServerFeature)
78
def get_bogus_url(self):
79
raise tests.UnavailableFeature(FTPServerFeature)
83
FTPTestServer = medusa_based.FTPTestServer
84
elif pyftpdlib_available:
85
FTPTestServer = pyftpdlib_based.FTPTestServer
87
FTPTestServer = UnavailableFTPTestServer