~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_http.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-12-22 18:18:20 UTC
  • mfrom: (4913.2.26 2.1.0rc1-module-available)
  • Revision ID: pqm@pqm.ubuntu.com-20091222181820-qfolh2sy2nevoxxj
(jam) Switch many test features over to ModuleAvailable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
    deprecated_in,
49
49
    )
50
50
from bzrlib.tests import (
 
51
    features,
51
52
    http_server,
52
53
    http_utils,
53
54
    )
61
62
    )
62
63
 
63
64
 
64
 
try:
 
65
if features.pycurl.available():
65
66
    from bzrlib.transport.http._pycurl import PyCurlTransport
66
 
    pycurl_present = True
67
 
except errors.DependencyNotPresent:
68
 
    pycurl_present = False
69
67
 
70
68
 
71
69
def load_tests(standard_tests, module, loader):
84
82
                        _server=http_server.HttpServer_urllib,
85
83
                        _qualified_prefix='http+urllib',)),
86
84
        ]
87
 
    if pycurl_present:
 
85
    if features.pycurl.available():
88
86
        transport_scenarios.append(
89
87
            ('pycurl', dict(_transport=PyCurlTransport,
90
88
                            _server=http_server.HttpServer_PyCurl,
156
154
        activity_scenarios.append(
157
155
            ('urllib,https', dict(_activity_server=ActivityHTTPSServer,
158
156
                                  _transport=_urllib.HttpTransport_urllib,)),)
159
 
    if pycurl_present:
 
157
    if features.pycurl.available():
160
158
        activity_scenarios.append(
161
159
            ('pycurl,http', dict(_activity_server=ActivityHTTPServer,
162
160
                                 _transport=PyCurlTransport,)),)
376
374
    """Test case to inherit from if pycurl is present"""
377
375
 
378
376
    def _get_pycurl_maybe(self):
379
 
        try:
380
 
            from bzrlib.transport.http._pycurl import PyCurlTransport
381
 
            return PyCurlTransport
382
 
        except errors.DependencyNotPresent:
383
 
            raise tests.TestSkipped('pycurl not present')
 
377
        self.requireFeature(features.pycurl)
 
378
        return PyCurlTransport
384
379
 
385
380
    _transport = property(_get_pycurl_maybe)
386
381
 
453
448
        https by supplying a fake version_info that do not
454
449
        support it.
455
450
        """
456
 
        try:
457
 
            import pycurl
458
 
        except ImportError:
459
 
            raise tests.TestSkipped('pycurl not present')
 
451
        self.requireFeature(features.pycurl)
460
452
 
461
453
        version_info_orig = pycurl.version_info
462
454
        try:
603
595
                                      protocol_version=self._protocol_version)
604
596
 
605
597
    def _testing_pycurl(self):
606
 
        return pycurl_present and self._transport == PyCurlTransport
 
598
        # TODO: This is duplicated for lots of the classes in this file
 
599
        return (features.pycurl.available()
 
600
                and self._transport == PyCurlTransport)
607
601
 
608
602
 
609
603
class WallRequestHandler(http_server.TestingHTTPRequestHandler):
718
712
    _req_handler_class = BadProtocolRequestHandler
719
713
 
720
714
    def setUp(self):
721
 
        if pycurl_present and self._transport == PyCurlTransport:
 
715
        if self._testing_pycurl():
722
716
            raise tests.TestNotApplicable(
723
717
                "pycurl doesn't check the protocol version")
724
718
        super(TestBadProtocolServer, self).setUp()
1187
1181
        self._old_env = {}
1188
1182
 
1189
1183
    def _testing_pycurl(self):
1190
 
        return pycurl_present and self._transport == PyCurlTransport
 
1184
        # TODO: This is duplicated for lots of the classes in this file
 
1185
        return (features.pycurl.available()
 
1186
                and self._transport == PyCurlTransport)
1191
1187
 
1192
1188
    def create_transport_secondary_server(self):
1193
1189
        """Creates an http server that will serve files with
1389
1385
    """
1390
1386
 
1391
1387
    def setUp(self):
1392
 
        if pycurl_present and self._transport == PyCurlTransport:
 
1388
        if (features.pycurl.available()
 
1389
            and self._transport == PyCurlTransport):
1393
1390
            raise tests.TestNotApplicable(
1394
1391
                "pycurl doesn't redirect silently annymore")
1395
1392
        super(TestHTTPSilentRedirections, self).setUp()
1507
1504
        return self._auth_server(protocol_version=self._protocol_version)
1508
1505
 
1509
1506
    def _testing_pycurl(self):
1510
 
        return pycurl_present and self._transport == PyCurlTransport
 
1507
        # TODO: This is duplicated for lots of the classes in this file
 
1508
        return (features.pycurl.available()
 
1509
                and self._transport == PyCurlTransport)
1511
1510
 
1512
1511
    def get_user_url(self, user, password):
1513
1512
        """Build an url embedding user and password"""