diff --git a/tests/functional/test_fast_deps.py b/tests/functional/test_fast_deps.py index a82684ce938..549de7eff41 100644 --- a/tests/functional/test_fast_deps.py +++ b/tests/functional/test_fast_deps.py @@ -7,7 +7,7 @@ from typing import Iterable from pip._vendor.packaging.utils import canonicalize_name -from pytest import mark +import pytest from pip._internal.utils.misc import hash_file from tests.lib import PipTestEnvironment, TestData, TestPipResult @@ -30,8 +30,8 @@ def assert_installed(script: PipTestEnvironment, names: str) -> None: assert installed.issuperset(map(canonicalize_name, names)) -@mark.network -@mark.parametrize( +@pytest.mark.network +@pytest.mark.parametrize( "requirement, expected", [ ("Paste==3.4.2", ("Paste", "six")), @@ -45,8 +45,8 @@ def test_install_from_pypi( assert_installed(script, expected) -@mark.network -@mark.parametrize( +@pytest.mark.network +@pytest.mark.parametrize( "requirement, expected", [ ("Paste==3.4.2", ("Paste-3.4.2-*.whl", "six-*.whl")), @@ -61,7 +61,7 @@ def test_download_from_pypi( assert all(fnmatch.filter(created, f) for f in expected) -@mark.network +@pytest.mark.network def test_build_wheel_with_deps(data: TestData, script: PipTestEnvironment) -> None: result = pip(script, "wheel", os.fspath(data.packages / "requiresPaste")) created = [basename(f) for f in result.files_created] @@ -70,7 +70,7 @@ def test_build_wheel_with_deps(data: TestData, script: PipTestEnvironment) -> No assert fnmatch.filter(created, "six-*.whl") -@mark.network +@pytest.mark.network def test_require_hash(script: PipTestEnvironment, tmp_path: pathlib.Path) -> None: reqs = tmp_path / "requirements.txt" reqs.write_text( @@ -91,7 +91,7 @@ def test_require_hash(script: PipTestEnvironment, tmp_path: pathlib.Path) -> Non assert fnmatch.filter(created, "idna-2.10*") -@mark.network +@pytest.mark.network def test_hash_mismatch(script: PipTestEnvironment, tmp_path: pathlib.Path) -> None: reqs = tmp_path / "requirements.txt" reqs.write_text("idna==2.10 --hash=sha256:irna") @@ -105,7 +105,7 @@ def test_hash_mismatch(script: PipTestEnvironment, tmp_path: pathlib.Path) -> No assert "DO NOT MATCH THE HASHES" in result.stderr -@mark.network +@pytest.mark.network def test_hash_mismatch_existing_download_for_metadata_only_wheel( script: PipTestEnvironment, tmp_path: pathlib.Path ) -> None: diff --git a/tests/unit/test_network_lazy_wheel.py b/tests/unit/test_network_lazy_wheel.py index 79e86321793..356387d2bba 100644 --- a/tests/unit/test_network_lazy_wheel.py +++ b/tests/unit/test_network_lazy_wheel.py @@ -1,7 +1,7 @@ from typing import Iterator +import pytest from pip._vendor.packaging.version import Version -from pytest import fixture, mark, raises from pip._internal.exceptions import InvalidWheel from pip._internal.network.lazy_wheel import ( @@ -25,12 +25,12 @@ } -@fixture +@pytest.fixture def session() -> PipSession: return PipSession() -@fixture +@pytest.fixture def mypy_whl_no_range(mock_server: MockServer, shared_data: TestData) -> Iterator[str]: mypy_whl = shared_data.packages / "mypy-0.782-py3-none-any.whl" mock_server.set_responses([file_response(mypy_whl)]) @@ -40,7 +40,7 @@ def mypy_whl_no_range(mock_server: MockServer, shared_data: TestData) -> Iterato mock_server.stop() -@mark.network +@pytest.mark.network def test_dist_from_wheel_url(session: PipSession) -> None: """Test if the acquired distribution contain correct information.""" dist = dist_from_wheel_url("mypy", MYPY_0_782_WHL, session) @@ -55,12 +55,12 @@ def test_dist_from_wheel_url_no_range( session: PipSession, mypy_whl_no_range: str ) -> None: """Test handling when HTTP range requests are not supported.""" - with raises(HTTPRangeRequestUnsupported): + with pytest.raises(HTTPRangeRequestUnsupported): dist_from_wheel_url("mypy", mypy_whl_no_range, session) -@mark.network +@pytest.mark.network def test_dist_from_wheel_url_not_zip(session: PipSession) -> None: """Test handling with the given URL does not point to a ZIP.""" - with raises(InvalidWheel): + with pytest.raises(InvalidWheel): dist_from_wheel_url("python", "https://www.python.org/", session)