mirror of https://github.com/pypa/pip
Use local server for an unit test for lazy wheel
This commit is contained in:
parent
db217992bd
commit
892018eaf2
Binary file not shown.
|
@ -8,7 +8,7 @@ from pip._internal.network.lazy_wheel import (
|
|||
dist_from_wheel_url,
|
||||
)
|
||||
from pip._internal.network.session import PipSession
|
||||
from tests.lib.requests_mocks import MockResponse
|
||||
from tests.lib.server import file_response
|
||||
|
||||
MYPY_0_782_WHL = (
|
||||
'https://files.pythonhosted.org/packages/9d/65/'
|
||||
|
@ -28,6 +28,16 @@ def session():
|
|||
return PipSession()
|
||||
|
||||
|
||||
@fixture
|
||||
def mypy_whl_no_range(mock_server, shared_data):
|
||||
mypy_whl = shared_data.packages / 'mypy-0.782-py3-none-any.whl'
|
||||
mock_server.set_responses([file_response(mypy_whl)])
|
||||
mock_server.start()
|
||||
base_address = 'http://{}:{}'.format(mock_server.host, mock_server.port)
|
||||
yield "{}/{}".format(base_address, 'mypy-0.782-py3-none-any.whl')
|
||||
mock_server.stop()
|
||||
|
||||
|
||||
@mark.network
|
||||
def test_dist_from_wheel_url(session):
|
||||
"""Test if the acquired distribution contain correct information."""
|
||||
|
@ -38,12 +48,10 @@ def test_dist_from_wheel_url(session):
|
|||
assert set(dist.requires(dist.extras)) == MYPY_0_782_REQS
|
||||
|
||||
|
||||
@mark.network
|
||||
def test_dist_from_wheel_url_no_range(session, monkeypatch):
|
||||
def test_dist_from_wheel_url_no_range(session, mypy_whl_no_range):
|
||||
"""Test handling when HTTP range requests are not supported."""
|
||||
monkeypatch.setattr(session, 'head', lambda *a, **kw: MockResponse(b''))
|
||||
with raises(HTTPRangeRequestUnsupported):
|
||||
dist_from_wheel_url('mypy', MYPY_0_782_WHL, session)
|
||||
dist_from_wheel_url('mypy', mypy_whl_no_range, session)
|
||||
|
||||
|
||||
@mark.network
|
||||
|
|
Loading…
Reference in New Issue