Skip to content

Commit

Permalink
update pytest.mark.network markers
Browse files Browse the repository at this point in the history
  • Loading branch information
dimbleby committed Mar 23, 2024
1 parent 8a8f21b commit 00fbe9e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
4 changes: 0 additions & 4 deletions tests/inspection/test_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,6 @@ def test_info_setup_simple(mocker: MockerFixture, demo_setup: Path) -> None:
demo_check_info(info, requires_dist={"package"})


@pytest.mark.network
def test_info_setup_complex(demo_setup_complex: Path) -> None:
info = PackageInfo.from_directory(demo_setup_complex)
demo_check_info(info, requires_dist={"package"})
Expand All @@ -334,22 +333,19 @@ def test_info_setup_complex_pep517_error(
PackageInfo.from_directory(demo_setup_complex)


@pytest.mark.network
def test_info_setup_complex_pep517_legacy(
demo_setup_complex_pep517_legacy: Path,
) -> None:
info = PackageInfo.from_directory(demo_setup_complex_pep517_legacy)
demo_check_info(info, requires_dist={"package"})


@pytest.mark.network
def test_info_setup_complex_calls_script(demo_setup_complex_calls_script: Path) -> None:
"""Building the project requires calling a script from its build_requires."""
info = PackageInfo.from_directory(demo_setup_complex_calls_script)
demo_check_info(info, requires_dist={"package"})


@pytest.mark.network
@pytest.mark.parametrize("missing", ["version", "name"])
def test_info_setup_missing_mandatory_should_trigger_pep517(
mocker: MockerFixture, source_dir: Path, missing: str
Expand Down
2 changes: 0 additions & 2 deletions tests/installation/test_chef.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ def test_prepare_directory(
os.unlink(wheel)


@pytest.mark.network
def test_prepare_directory_with_extensions(
config: Config,
config_cache_dir: Path,
Expand Down Expand Up @@ -126,7 +125,6 @@ def test_prepare_directory_editable(
os.unlink(wheel)


@pytest.mark.network
def test_prepare_directory_script(
config: Config,
config_cache_dir: Path,
Expand Down
5 changes: 0 additions & 5 deletions tests/installation/test_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1547,11 +1547,6 @@ def test_executor_known_hashes(
io: BufferedIO,
fixture_dir: FixtureDirGetter,
) -> None:
# when installing sdist, an isolated build environment is required to extract metadata
# this will install any build system requirements into the environment, to avoid failures when
# network is not available we enable mock_file_downloads fixture here
# see: https://github.com/python-poetry/poetry/issues/9114

package_source_url: Path = (
fixture_dir("distributions") / "demo-0.1.0.tar.gz"
).resolve()
Expand Down
18 changes: 18 additions & 0 deletions tests/integration/test_utils_vcs_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ def test_use_system_git_client_from_environment_variables() -> None:
assert Git.is_using_legacy_client()


@pytest.mark.network
def test_git_local_info(
source_url: str, remote_refs: FetchPackResult, remote_default_ref: bytes
) -> None:
Expand All @@ -143,6 +144,7 @@ def test_git_local_info(
assert info.revision == remote_refs.refs[remote_default_ref].decode("utf-8")


@pytest.mark.network
@pytest.mark.parametrize(
"specification", [{}, {"revision": "HEAD"}, {"branch": "HEAD"}]
)
Expand All @@ -163,6 +165,7 @@ def test_git_clone_default_branch_head(
spy.assert_called()


@pytest.mark.network
def test_git_clone_fails_for_non_existent_branch(source_url: str) -> None:
branch = uuid.uuid4().hex

Expand All @@ -172,6 +175,7 @@ def test_git_clone_fails_for_non_existent_branch(source_url: str) -> None:
assert f"Failed to clone {source_url} at '{branch}'" in str(e.value)


@pytest.mark.network
def test_git_clone_fails_for_non_existent_revision(source_url: str) -> None:
revision = sha1(uuid.uuid4().bytes).hexdigest()

Expand All @@ -193,11 +197,13 @@ def assert_version(repo: Repo, expected_revision: str) -> None:
assert version == REVISION_TO_VERSION_MAP[revision]


@pytest.mark.network
def test_git_clone_when_branch_is_ref(source_url: str) -> None:
with Git.clone(url=source_url, branch="refs/heads/0.1") as repo:
assert_version(repo, BRANCH_TO_REVISION_MAP["0.1"])


@pytest.mark.network
@pytest.mark.parametrize("branch", [*BRANCH_TO_REVISION_MAP.keys()])
def test_git_clone_branch(
source_url: str, remote_refs: FetchPackResult, branch: str
Expand All @@ -206,12 +212,14 @@ def test_git_clone_branch(
assert_version(repo, BRANCH_TO_REVISION_MAP[branch])


@pytest.mark.network
@pytest.mark.parametrize("tag", [*TAG_TO_REVISION_MAP.keys()])
def test_git_clone_tag(source_url: str, remote_refs: FetchPackResult, tag: str) -> None:
with Git.clone(url=source_url, tag=tag) as repo:
assert_version(repo, TAG_TO_REVISION_MAP[tag])


@pytest.mark.network
def test_git_clone_multiple_times(
source_url: str, remote_refs: FetchPackResult
) -> None:
Expand All @@ -220,20 +228,23 @@ def test_git_clone_multiple_times(
assert_version(repo, revision)


@pytest.mark.network
def test_git_clone_revision_is_branch(
source_url: str, remote_refs: FetchPackResult
) -> None:
with Git.clone(url=source_url, revision="0.1") as repo:
assert_version(repo, BRANCH_TO_REVISION_MAP["0.1"])


@pytest.mark.network
def test_git_clone_revision_is_ref(
source_url: str, remote_refs: FetchPackResult
) -> None:
with Git.clone(url=source_url, revision="refs/heads/0.1") as repo:
assert_version(repo, BRANCH_TO_REVISION_MAP["0.1"])


@pytest.mark.network
@pytest.mark.parametrize(
("revision", "expected_revision"),
[
Expand All @@ -249,6 +260,7 @@ def test_git_clone_revision_is_tag(
assert_version(repo, expected_revision)


@pytest.mark.network
def test_git_clone_clones_submodules(source_url: str) -> None:
with Git.clone(url=source_url) as repo:
submodule_package_directory = (
Expand All @@ -260,6 +272,7 @@ def test_git_clone_clones_submodules(source_url: str) -> None:
assert len(list(submodule_package_directory.glob("*"))) > 1


@pytest.mark.network
def test_git_clone_clones_submodules_with_relative_urls(source_url: str) -> None:
with Git.clone(url=source_url, branch="relative_submodule") as repo:
submodule_package_directory = (
Expand All @@ -271,6 +284,7 @@ def test_git_clone_clones_submodules_with_relative_urls(source_url: str) -> None
assert len(list(submodule_package_directory.glob("*"))) > 1


@pytest.mark.network
def test_git_clone_clones_submodules_with_relative_urls_and_explicit_base(
source_url: str,
) -> None:
Expand All @@ -284,6 +298,7 @@ def test_git_clone_clones_submodules_with_relative_urls_and_explicit_base(
assert len(list(submodule_package_directory.glob("*"))) > 1


@pytest.mark.network
def test_system_git_fallback_on_http_401(
mocker: MockerFixture,
source_url: str,
Expand Down Expand Up @@ -361,6 +376,7 @@ def test_configured_repository_http_auth(
spy_get_transport_and_path.assert_called_once()


@pytest.mark.network
def test_username_password_parameter_is_not_passed_to_dulwich(
mocker: MockerFixture, source_url: str, config: Config
) -> None:
Expand All @@ -387,6 +403,7 @@ def test_username_password_parameter_is_not_passed_to_dulwich(
spy_get_transport_and_path.assert_called_once()


@pytest.mark.network
def test_system_git_called_when_configured(
mocker: MockerFixture, source_url: str, use_system_git_client: None
) -> None:
Expand All @@ -407,6 +424,7 @@ def test_system_git_called_when_configured(
)


@pytest.mark.network
def test_relative_submodules_with_ssh(
source_url: str, tmpdir: Path, mocker: MockerFixture
) -> None:
Expand Down

0 comments on commit 00fbe9e

Please sign in to comment.