diff --git a/tests/unit/test_index.py b/tests/unit/test_index.py index 5acbbafad04..ce81a9deb02 100644 --- a/tests/unit/test_index.py +++ b/tests/unit/test_index.py @@ -7,7 +7,7 @@ from pip._internal.download import PipSession from pip._internal.index import ( - HTMLPage, Link, PackageFinder, _determine_base_url, egg_info_matches, + Link, PackageFinder, _determine_base_url, _get_html_page, egg_info_matches, ) @@ -194,21 +194,26 @@ def test_egg_info_matches(egg_info, search_name, expected): assert version == expected -@pytest.mark.parametrize( - ('exception', 'message'), - [ - (requests.HTTPError, 'Http error'), - (requests.exceptions.RetryError, 'Retry error'), - ], -) -def test_request_retries(exception, message, caplog): +def test_request_http_error(caplog): caplog.set_level(logging.DEBUG) 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 + resp.raise_for_status.side_effect = requests.HTTPError('Http error') + assert _get_html_page(link, session=session) is None + assert ( + 'Could not fetch URL http://localhost: Http error - skipping' + in caplog.text + ) + + +def test_request_retries(caplog): + caplog.set_level(logging.DEBUG) + link = Link('http://localhost') + session = Mock(PipSession) + session.get.side_effect = requests.exceptions.RetryError('Retry error') + assert _get_html_page(link, session=session) is None assert ( - 'Could not fetch URL http://localhost: %s - skipping' % message + 'Could not fetch URL http://localhost: Retry error - skipping' in caplog.text )