bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
4763.2.4
by John Arbash Meinel
merge bzr.2.1 in preparation for NEWS entry. |
1 |
# Copyright (C) 2009, 2010 Canonical Ltd
|
|
3508.1.7
by Vincent Ladeuil
Prepare test framework for pyftpdlib injection. |
2 |
#
|
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.
|
|
7 |
#
|
|
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.
|
|
12 |
#
|
|
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
|
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
3508.1.7
by Vincent Ladeuil
Prepare test framework for pyftpdlib injection. |
16 |
"""
|
17 |
Facilities to use ftp test servers.
|
|
18 |
"""
|
|
19 |
||
20 |
from bzrlib import tests |
|
21 |
||
22 |
||
23 |
try: |
|
|
3508.1.10
by Vincent Ladeuil
Start supporting pyftpdlib as an ftp test server. |
24 |
from bzrlib.tests.ftp_server import pyftpdlib_based |
25 |
pyftpdlib_available = True |
|
26 |
except ImportError: |
|
27 |
pyftpdlib_available = False |
|
28 |
||
29 |
||
|
3508.1.7
by Vincent Ladeuil
Prepare test framework for pyftpdlib injection. |
30 |
class _FTPServerFeature(tests.Feature): |
31 |
"""Some tests want an FTP Server, check if one is available. |
|
32 |
||
|
3508.1.23
by Vincent Ladeuil
Fix as per Martin's review. |
33 |
Right now, the only way this is available is if one of the following is
|
34 |
installed:
|
|
35 |
||
36 |
- 'medusa': http://www.amk.ca/python/code/medusa.html
|
|
37 |
- 'pyftpdlib': http://code.google.com/p/pyftpdlib/
|
|
|
3508.1.7
by Vincent Ladeuil
Prepare test framework for pyftpdlib injection. |
38 |
"""
|
39 |
||
40 |
def _probe(self): |
|
|
5848.2.1
by John Arbash Meinel
Break compatibility with python <2.6. |
41 |
return pyftpdlib_available |
|
3508.1.7
by Vincent Ladeuil
Prepare test framework for pyftpdlib injection. |
42 |
|
43 |
def feature_name(self): |
|
44 |
return 'FTPServer' |
|
45 |
||
46 |
||
47 |
FTPServerFeature = _FTPServerFeature() |
|
48 |
||
49 |
||
|
4167.1.2
by Vincent Ladeuil
Fix UnavailableFTPTestServer for sites without medusa and pyftpdlib. |
50 |
class UnavailableFTPTestServer(object): |
|
3508.1.7
by Vincent Ladeuil
Prepare test framework for pyftpdlib injection. |
51 |
"""Dummy ftp test server. |
52 |
||
53 |
This allows the test suite report the number of tests needing that
|
|
54 |
feature. We raise UnavailableFeature from methods before the test server is
|
|
55 |
being used. Doing so in the setUp method has bad side-effects (tearDown is
|
|
56 |
never called).
|
|
57 |
"""
|
|
58 |
||
|
4934.3.3
by Martin Pool
Rename Server.setUp to Server.start_server |
59 |
def start_server(self, vfs_server=None): |
|
3508.1.7
by Vincent Ladeuil
Prepare test framework for pyftpdlib injection. |
60 |
pass
|
61 |
||
|
4934.3.1
by Martin Pool
Rename Server.tearDown to .stop_server |
62 |
def stop_server(self): |
|
3508.1.7
by Vincent Ladeuil
Prepare test framework for pyftpdlib injection. |
63 |
pass
|
64 |
||
65 |
def get_url(self): |
|
66 |
raise tests.UnavailableFeature(FTPServerFeature) |
|
67 |
||
68 |
def get_bogus_url(self): |
|
69 |
raise tests.UnavailableFeature(FTPServerFeature) |
|
70 |
||
71 |
||
|
5848.2.1
by John Arbash Meinel
Break compatibility with python <2.6. |
72 |
if pyftpdlib_available: |
|
3508.1.23
by Vincent Ladeuil
Fix as per Martin's review. |
73 |
FTPTestServer = pyftpdlib_based.FTPTestServer |
|
3508.1.7
by Vincent Ladeuil
Prepare test framework for pyftpdlib injection. |
74 |
else: |
|
3508.1.23
by Vincent Ladeuil
Fix as per Martin's review. |
75 |
FTPTestServer = UnavailableFTPTestServer |