def __init__(self, index_url="https://pypi.python.org/simple", hosts=('*',), ca_bundle=None, verify_ssl=True, *args, **kw ): Environment.__init__(self,*args,**kw) self.index_url = index_url + "/"[:not index_url.endswith('/')] self.scanned_urls = {} self.fetched_urls = {} self.package_pages = {} self.allows = re.compile('|'.join(map(translate,hosts))).match self.to_scan = [] if verify_ssl and ssl_support.is_available and (ca_bundle or ssl_support.find_ca_bundle()): self.opener = ssl_support.opener_for(ca_bundle) else: self.opener = urllib2.urlopen
def __init__(self, index_url="https://pypi.python.org/simple", hosts=("*", ), ca_bundle=None, verify_ssl=True, *args, **kw): Environment.__init__(self, *args, **kw) self.index_url = index_url + "/"[:not index_url.endswith("/")] self.scanned_urls = {} self.fetched_urls = {} self.package_pages = {} self.allows = re.compile("|".join(map(translate, hosts))).match self.to_scan = [] use_ssl = (verify_ssl and ssl_support.is_available and (ca_bundle or ssl_support.find_ca_bundle())) if use_ssl: self.opener = ssl_support.opener_for(ca_bundle) else: self.opener = urllib.request.urlopen
from unittest.mock import patch, MagicMock from threading import Thread, Event from multiprocessing import Process from decimal import Decimal import datetime as dt import urllib3.exceptions from base64 import b64decode from urllib.parse import urlparse, parse_qs from setuptools.ssl_support import find_ca_bundle from .http import Client, _get_socket_opts, _remove_certs_for_non_https from .exceptions import ConnectionError, ProgrammingError REQUEST = 'crate.client.http.Server.request' CA_CERT_PATH = find_ca_bundle() def fake_request(response=None): def request(*args, **kwargs): if isinstance(response, list): resp = response.pop(0) response.append(resp) return resp elif response: return response else: return MagicMock(spec=urllib3.response.HTTPResponse) return request