Python requests.packages() Examples

The following are code examples for showing how to use requests.packages(). They are extracted from open source Python projects. You can vote up the examples you like or vote down the ones you don't like. You can also save this page to your account.

Example 1
Project: python-zhmcclient   Author: zhmcclient   File: _session.py    (license) View Source Project 6 votes vote down vote up
def _new_session(retry_timeout_config):
        """
        Return a new `requests.Session` object.
        """
        retry = requests.packages.urllib3.Retry(
            total=None,
            connect=retry_timeout_config.connect_retries,
            read=retry_timeout_config.read_retries,
            method_whitelist=retry_timeout_config.method_whitelist,
            redirect=retry_timeout_config.max_redirects)
        session = requests.Session()
        session.mount('https://',
                      requests.adapters.HTTPAdapter(max_retries=retry))
        session.mount('http://',
                      requests.adapters.HTTPAdapter(max_retries=retry))
        return session 
Example 2
Project: ruffruffs   Author: di   File: test_requests.py    (license) View Source Project 5 votes vote down vote up
def test_urllib3_retries(httpbin):
    from requests.packages.urllib3.util import Retry
    s = requests.Session()
    s.mount('http://', HTTPAdapter(max_retries=Retry(
        total=2, status_forcelist=[500]
    )))

    with pytest.raises(RetryError):
        s.get(httpbin('status/500')) 
Example 3
Project: ruffruffs   Author: di   File: test_requests.py    (license) View Source Project 5 votes vote down vote up
def test_vendor_aliases():
    from requests.packages import urllib3
    from requests.packages import chardet

    with pytest.raises(ImportError):
        from requests.packages import webbrowser 
Example 4
Project: filegardener   Author: smorin   File: test_requests.py    (license) View Source Project 5 votes vote down vote up
def test_urllib3_retries(httpbin):
    from requests.packages.urllib3.util import Retry
    s = requests.Session()
    s.mount('http://', HTTPAdapter(max_retries=Retry(
        total=2, status_forcelist=[500]
    )))

    with pytest.raises(RetryError):
        s.get(httpbin('status/500')) 
Example 5
Project: filegardener   Author: smorin   File: test_requests.py    (license) View Source Project 5 votes vote down vote up
def test_vendor_aliases():
    from requests.packages import urllib3
    from requests.packages import chardet

    with pytest.raises(ImportError):
        from requests.packages import webbrowser 
Example 6
Project: filegardener   Author: smorin   File: test_requests.py    (license) View Source Project 5 votes vote down vote up
def test_urllib3_retries(httpbin):
    from requests.packages.urllib3.util import Retry
    s = requests.Session()
    s.mount('http://', HTTPAdapter(max_retries=Retry(
        total=2, status_forcelist=[500]
    )))

    with pytest.raises(RetryError):
        s.get(httpbin('status/500')) 
Example 7
Project: filegardener   Author: smorin   File: test_requests.py    (license) View Source Project 5 votes vote down vote up
def test_vendor_aliases():
    from requests.packages import urllib3
    from requests.packages import chardet

    with pytest.raises(ImportError):
        from requests.packages import webbrowser 
Example 8
Project: Codeforces-Sublime-Plugin   Author: karunk   File: test_requests.py    (license) View Source Project 5 votes vote down vote up
def test_urllib3_retries(httpbin):
    from requests.packages.urllib3.util import Retry
    s = requests.Session()
    s.mount('http://', HTTPAdapter(max_retries=Retry(
        total=2, status_forcelist=[500]
    )))

    with pytest.raises(RetryError):
        s.get(httpbin('status/500')) 
Example 9
Project: Codeforces-Sublime-Plugin   Author: karunk   File: test_requests.py    (license) View Source Project 5 votes vote down vote up
def test_vendor_aliases():
    from requests.packages import urllib3
    from requests.packages import chardet

    with pytest.raises(ImportError):
        from requests.packages import webbrowser