Skip to content

chore(ci): disable external network calls #13142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ follow_imports = "skip"
#

[tool.pytest.ini_options]
addopts = "--ignore src/pip/_vendor --ignore tests/tests_cache -r aR --color=yes"
addopts = "--ignore src/pip/_vendor --ignore tests/tests_cache -r aR --color=yes --disable-socket --allow-hosts=localhost"
xfail_strict = true
markers = [
"network: tests that need network",
Expand Down
2 changes: 2 additions & 0 deletions tests/functional/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def test_list_all_versions_search_with_pre(script: PipTestEnvironment) -> None:
)


@pytest.mark.enable_socket
@pytest.mark.network
def test_list_all_versions_returns_no_matches_found_when_name_not_exact() -> None:
"""
Expand All @@ -63,6 +64,7 @@ def test_list_all_versions_returns_no_matches_found_when_name_not_exact() -> Non
assert status == ERROR


@pytest.mark.enable_socket
@pytest.mark.network
def test_list_all_versions_returns_matches_found_when_name_is_exact() -> None:
"""
Expand Down
1 change: 1 addition & 0 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ installer
pytest
pytest-cov
pytest-rerunfailures
pytest-socket
pytest-xdist
scripttest
setuptools
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/test_network_lazy_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def mypy_whl_no_range(mock_server: MockServer, shared_data: TestData) -> Iterato
mock_server.stop()


@pytest.mark.enable_socket
@pytest.mark.network
def test_dist_from_wheel_url(session: PipSession) -> None:
"""Test if the acquired distribution contain correct information."""
Expand All @@ -53,6 +54,7 @@ def test_dist_from_wheel_url(session: PipSession) -> None:
assert {str(d) for d in dist.iter_dependencies(extras)} == MYPY_0_782_REQS


@pytest.mark.enable_socket
def test_dist_from_wheel_url_no_range(
session: PipSession, mypy_whl_no_range: str
) -> None:
Expand All @@ -61,6 +63,7 @@ def test_dist_from_wheel_url_no_range(
dist_from_wheel_url("mypy", mypy_whl_no_range, session)


@pytest.mark.enable_socket
@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."""
Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_network_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ def warning(self, *args: Any, **kwargs: Any) -> None:
assert actual_level == "WARNING"
assert "is not a trusted or secure host" in actual_message

@pytest.mark.enable_socket
@pytest.mark.network
def test_proxy(self, proxy: Optional[str]) -> None:
session = PipSession(trusted_hosts=[])
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/test_req.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ def test_download_info_find_links(self, data: TestData) -> None:
assert isinstance(req.download_info.info, ArchiveInfo)
assert req.download_info.info.hash

@pytest.mark.enable_socket
@pytest.mark.network
def test_download_info_index_url(self) -> None:
"""Test that download_info is set for requirements via index."""
Expand All @@ -377,6 +378,7 @@ def test_download_info_index_url(self) -> None:
assert req.download_info
assert isinstance(req.download_info.info, ArchiveInfo)

@pytest.mark.enable_socket
@pytest.mark.network
def test_download_info_web_archive(self) -> None:
"""Test that download_info is set for requirements from a web archive."""
Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_req_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,7 @@ def test_variant5(
class TestParseRequirements:
"""tests for `parse_reqfile`"""

@pytest.mark.enable_socket
@pytest.mark.network
def test_remote_reqs_parse(self) -> None:
"""
Expand Down
Loading