65
if features.pycurl.available():
66
65
from bzrlib.transport.http._pycurl import PyCurlTransport
67
except errors.DependencyNotPresent:
68
pycurl_present = False
69
71
def load_tests(standard_tests, module, loader):
82
84
_server=http_server.HttpServer_urllib,
83
85
_qualified_prefix='http+urllib',)),
85
if features.pycurl.available():
86
88
transport_scenarios.append(
87
89
('pycurl', dict(_transport=PyCurlTransport,
88
90
_server=http_server.HttpServer_PyCurl,
154
156
activity_scenarios.append(
155
157
('urllib,https', dict(_activity_server=ActivityHTTPSServer,
156
158
_transport=_urllib.HttpTransport_urllib,)),)
157
if features.pycurl.available():
158
160
activity_scenarios.append(
159
161
('pycurl,http', dict(_activity_server=ActivityHTTPServer,
160
162
_transport=PyCurlTransport,)),)
374
376
"""Test case to inherit from if pycurl is present"""
376
378
def _get_pycurl_maybe(self):
377
self.requireFeature(features.pycurl)
378
return PyCurlTransport
380
from bzrlib.transport.http._pycurl import PyCurlTransport
381
return PyCurlTransport
382
except errors.DependencyNotPresent:
383
raise tests.TestSkipped('pycurl not present')
380
385
_transport = property(_get_pycurl_maybe)
448
453
https by supplying a fake version_info that do not
451
self.requireFeature(features.pycurl)
452
# Import the module locally now that we now it's available.
453
pycurl = features.pycurl.module
459
raise tests.TestSkipped('pycurl not present')
455
461
version_info_orig = pycurl.version_info
463
# Now that we have pycurl imported, we can fake its version_info
464
# This was taken from a windows pycurl without SSL
466
pycurl.version_info = lambda : (2,
474
('ftp', 'gopher', 'telnet',
475
'dict', 'ldap', 'http', 'file'),
479
self.assertRaises(errors.DependencyNotPresent, self._transport,
480
'https://launchpad.net')
482
# Restore the right function
457
483
pycurl.version_info = version_info_orig
458
self.addCleanup(restore)
460
# Fake the pycurl version_info This was taken from a windows pycurl
461
# without SSL (thanks to bialix)
462
pycurl.version_info = lambda : (2,
470
('ftp', 'gopher', 'telnet',
471
'dict', 'ldap', 'http', 'file'),
475
self.assertRaises(errors.DependencyNotPresent, self._transport,
476
'https://launchpad.net')
479
486
class TestHTTPConnections(http_utils.TestCaseWithWebserver):
596
603
protocol_version=self._protocol_version)
598
605
def _testing_pycurl(self):
599
# TODO: This is duplicated for lots of the classes in this file
600
return (features.pycurl.available()
601
and self._transport == PyCurlTransport)
606
return pycurl_present and self._transport == PyCurlTransport
604
609
class WallRequestHandler(http_server.TestingHTTPRequestHandler):
713
718
_req_handler_class = BadProtocolRequestHandler
716
if self._testing_pycurl():
721
if pycurl_present and self._transport == PyCurlTransport:
717
722
raise tests.TestNotApplicable(
718
723
"pycurl doesn't check the protocol version")
719
724
super(TestBadProtocolServer, self).setUp()
1182
1187
self._old_env = {}
1184
1189
def _testing_pycurl(self):
1185
# TODO: This is duplicated for lots of the classes in this file
1186
return (features.pycurl.available()
1187
and self._transport == PyCurlTransport)
1190
return pycurl_present and self._transport == PyCurlTransport
1189
1192
def create_transport_secondary_server(self):
1190
1193
"""Creates an http server that will serve files with
1388
1391
def setUp(self):
1389
if (features.pycurl.available()
1390
and self._transport == PyCurlTransport):
1392
if pycurl_present and self._transport == PyCurlTransport:
1391
1393
raise tests.TestNotApplicable(
1392
1394
"pycurl doesn't redirect silently annymore")
1393
1395
super(TestHTTPSilentRedirections, self).setUp()
1505
1507
return self._auth_server(protocol_version=self._protocol_version)
1507
1509
def _testing_pycurl(self):
1508
# TODO: This is duplicated for lots of the classes in this file
1509
return (features.pycurl.available()
1510
and self._transport == PyCurlTransport)
1510
return pycurl_present and self._transport == PyCurlTransport
1512
1512
def get_user_url(self, user, password):
1513
1513
"""Build an url embedding user and password"""