65
if features.pycurl.available():
65
66
from bzrlib.transport.http._pycurl import PyCurlTransport
67
except errors.DependencyNotPresent:
68
pycurl_present = False
71
69
def load_tests(standard_tests, module, loader):
84
82
_server=http_server.HttpServer_urllib,
85
83
_qualified_prefix='http+urllib',)),
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,)),)
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"""
378
376
def _get_pycurl_maybe(self):
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
385
380
_transport = property(_get_pycurl_maybe)
453
448
https by supplying a fake version_info that do not
459
raise tests.TestSkipped('pycurl not present')
451
self.requireFeature(features.pycurl)
452
# Import the module locally now that we now it's available.
453
pycurl = features.pycurl.module
461
455
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
483
457
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')
486
479
class TestHTTPConnections(http_utils.TestCaseWithWebserver):
603
596
protocol_version=self._protocol_version)
605
598
def _testing_pycurl(self):
606
return pycurl_present and self._transport == PyCurlTransport
599
# TODO: This is duplicated for lots of the classes in this file
600
return (features.pycurl.available()
601
and self._transport == PyCurlTransport)
609
604
class WallRequestHandler(http_server.TestingHTTPRequestHandler):
718
713
_req_handler_class = BadProtocolRequestHandler
721
if pycurl_present and self._transport == PyCurlTransport:
716
if self._testing_pycurl():
722
717
raise tests.TestNotApplicable(
723
718
"pycurl doesn't check the protocol version")
724
719
super(TestBadProtocolServer, self).setUp()
1187
1182
self._old_env = {}
1189
1184
def _testing_pycurl(self):
1190
return pycurl_present and self._transport == PyCurlTransport
1185
# TODO: This is duplicated for lots of the classes in this file
1186
return (features.pycurl.available()
1187
and self._transport == PyCurlTransport)
1192
1189
def create_transport_secondary_server(self):
1193
1190
"""Creates an http server that will serve files with
1391
1388
def setUp(self):
1392
if pycurl_present and self._transport == PyCurlTransport:
1389
if (features.pycurl.available()
1390
and self._transport == PyCurlTransport):
1393
1391
raise tests.TestNotApplicable(
1394
1392
"pycurl doesn't redirect silently annymore")
1395
1393
super(TestHTTPSilentRedirections, self).setUp()
1507
1505
return self._auth_server(protocol_version=self._protocol_version)
1509
1507
def _testing_pycurl(self):
1510
return pycurl_present and self._transport == PyCurlTransport
1508
# TODO: This is duplicated for lots of the classes in this file
1509
return (features.pycurl.available()
1510
and self._transport == PyCurlTransport)
1512
1512
def get_user_url(self, user, password):
1513
1513
"""Build an url embedding user and password"""