/brz/remove-bazaar

To get this branch, use:
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
5967.12.1 by Martin Pool
Move all test features into bzrlib.tests.features
16
3508.1.7 by Vincent Ladeuil
Prepare test framework for pyftpdlib injection.
17
"""
18
Facilities to use ftp test servers.
19
"""
20
5947.1.1 by Vincent Ladeuil
Support pyftplib-0.6.0 as an ftp test server
21
import sys
22
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
23
from breezy import tests
24
from breezy.tests import (
5967.12.1 by Martin Pool
Move all test features into bzrlib.tests.features
25
    features,
26
    )
3508.1.7 by Vincent Ladeuil
Prepare test framework for pyftpdlib injection.
27
28
29
try:
6686.1.2 by Jelmer Vernooij
Initial work to get pyftpdlib to work again.
30
    import pyftpdlib
3508.1.10 by Vincent Ladeuil
Start supporting pyftpdlib as an ftp test server.
31
except ImportError:
32
    pyftpdlib_available = False
6686.1.2 by Jelmer Vernooij
Initial work to get pyftpdlib to work again.
33
else:
34
    pyftpdlib_available = True
3508.1.10 by Vincent Ladeuil
Start supporting pyftpdlib as an ftp test server.
35
36
5967.12.1 by Martin Pool
Move all test features into bzrlib.tests.features
37
class _FTPServerFeature(features.Feature):
3508.1.7 by Vincent Ladeuil
Prepare test framework for pyftpdlib injection.
38
    """Some tests want an FTP Server, check if one is available.
39
3508.1.23 by Vincent Ladeuil
Fix as per Martin's review.
40
    Right now, the only way this is available is if one of the following is
41
    installed:
42
43
    - 'pyftpdlib': http://code.google.com/p/pyftpdlib/
3508.1.7 by Vincent Ladeuil
Prepare test framework for pyftpdlib injection.
44
    """
45
46
    def _probe(self):
6686.1.1 by Jelmer Vernooij
Drop support for medusa.
47
        return pyftpdlib_available
3508.1.7 by Vincent Ladeuil
Prepare test framework for pyftpdlib injection.
48
49
    def feature_name(self):
50
        return 'FTPServer'
51
52
53
FTPServerFeature = _FTPServerFeature()
54
55
4167.1.2 by Vincent Ladeuil
Fix UnavailableFTPTestServer for sites without medusa and pyftpdlib.
56
class UnavailableFTPTestServer(object):
3508.1.7 by Vincent Ladeuil
Prepare test framework for pyftpdlib injection.
57
    """Dummy ftp test server.
58
59
    This allows the test suite report the number of tests needing that
60
    feature. We raise UnavailableFeature from methods before the test server is
61
    being used. Doing so in the setUp method has bad side-effects (tearDown is
62
    never called).
63
    """
64
4934.3.3 by Martin Pool
Rename Server.setUp to Server.start_server
65
    def start_server(self, vfs_server=None):
3508.1.7 by Vincent Ladeuil
Prepare test framework for pyftpdlib injection.
66
        pass
67
4934.3.1 by Martin Pool
Rename Server.tearDown to .stop_server
68
    def stop_server(self):
3508.1.7 by Vincent Ladeuil
Prepare test framework for pyftpdlib injection.
69
        pass
70
71
    def get_url(self):
72
        raise tests.UnavailableFeature(FTPServerFeature)
73
74
    def get_bogus_url(self):
75
        raise tests.UnavailableFeature(FTPServerFeature)
76
77
6686.1.1 by Jelmer Vernooij
Drop support for medusa.
78
if pyftpdlib_available:
6686.1.2 by Jelmer Vernooij
Initial work to get pyftpdlib to work again.
79
    from . import pyftpdlib_based
3508.1.23 by Vincent Ladeuil
Fix as per Martin's review.
80
    FTPTestServer = pyftpdlib_based.FTPTestServer
3508.1.7 by Vincent Ladeuil
Prepare test framework for pyftpdlib injection.
81
else:
3508.1.23 by Vincent Ladeuil
Fix as per Martin's review.
82
    FTPTestServer = UnavailableFTPTestServer