mirror of
https://github.com/pypa/pip
synced 2023-12-13 21:30:23 +01:00
add failing test for HTMLPage.get_page raising RetryError
This commit is contained in:
parent
b6bbabe3e7
commit
b36d91c2a6
|
@ -1,11 +1,12 @@
|
|||
import os.path
|
||||
|
||||
import pytest
|
||||
from pip._vendor import html5lib
|
||||
from mock import Mock
|
||||
from pip._vendor import html5lib, requests
|
||||
|
||||
from pip._internal.download import PipSession
|
||||
from pip._internal.index import (
|
||||
Link, PackageFinder, _determine_base_url, egg_info_matches,
|
||||
HTMLPage, Link, PackageFinder, _determine_base_url, egg_info_matches,
|
||||
)
|
||||
|
||||
|
||||
|
@ -190,3 +191,22 @@ def test_egg_info_matches(egg_info, search_name, expected):
|
|||
link = None # Only used for reporting.
|
||||
version = egg_info_matches(egg_info, search_name, link)
|
||||
assert version == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
('exception', 'message'),
|
||||
[
|
||||
(requests.HTTPError, 'Http error'),
|
||||
(requests.exceptions.RetryError, 'Retry error'),
|
||||
],
|
||||
)
|
||||
def test_request_retries(exception, message, caplog):
|
||||
link = Link('http://localhost')
|
||||
session = Mock(PipSession)
|
||||
session.get.return_value = resp = Mock()
|
||||
resp.raise_for_status.side_effect = exception(message)
|
||||
assert HTMLPage.get_page(link, session=session) is None
|
||||
assert (
|
||||
'Could not fetch URL http://localhost: %s - skipping' % message
|
||||
in caplog.text
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue