Skip to content

Commit

Permalink
add typehints to tests.installation.test_pip_installer
Browse files Browse the repository at this point in the history
  • Loading branch information
finswimmer committed Nov 19, 2021
1 parent ace0b1a commit f527c3a
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions tests/installation/test_pip_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import shutil

from pathlib import Path
from typing import TYPE_CHECKING

import pytest

Expand All @@ -14,8 +15,14 @@
from poetry.utils.env import NullEnv


if TYPE_CHECKING:
from pytest_mock import MockerFixture

from poetry.utils.env import VirtualEnv


@pytest.fixture
def package_git():
def package_git() -> Package:
package = Package(
"demo",
"1.0.0",
Expand All @@ -28,16 +35,16 @@ def package_git():


@pytest.fixture
def pool():
def pool() -> Pool:
return Pool()


@pytest.fixture
def installer(pool):
def installer(pool: Pool) -> PipInstaller:
return PipInstaller(NullEnv(), NullIO(), pool)


def test_requirement(installer):
def test_requirement(installer: PipInstaller):
package = Package("ipython", "7.5.0")
package.files = [
{"file": "foo-0.1.0.tar.gz", "hash": "md5:dbdc53e3918f28fa335a173432402a00"},
Expand Down Expand Up @@ -74,15 +81,15 @@ def test_requirement_source_type_url():
assert expected == result


def test_requirement_git_develop_false(installer, package_git):
def test_requirement_git_develop_false(installer: PipInstaller, package_git: Package):
package_git.develop = False
result = installer.requirement(package_git)
expected = "git+git@github.com:demo/demo.git@master#egg=demo"

assert expected == result


def test_install_with_non_pypi_default_repository(pool, installer):
def test_install_with_non_pypi_default_repository(pool: Pool, installer: PipInstaller):
default = LegacyRepository("default", "https://default.com")
another = LegacyRepository("another", "https://another.com")

Expand Down Expand Up @@ -170,15 +177,17 @@ def test_install_with_client_cert():
assert cmd[cert_index + 1] == str(Path(client_path))


def test_requirement_git_develop_true(installer, package_git):
def test_requirement_git_develop_true(installer: PipInstaller, package_git: Package):
package_git.develop = True
result = installer.requirement(package_git)
expected = ["-e", "git+git@github.com:demo/demo.git@master#egg=demo"]

assert expected == result


def test_uninstall_git_package_nspkg_pth_cleanup(mocker, tmp_venv, pool):
def test_uninstall_git_package_nspkg_pth_cleanup(
mocker: "MockerFixture", tmp_venv: "VirtualEnv", pool: Pool
):
# this test scenario requires a real installation using the pip installer
installer = PipInstaller(tmp_venv, NullIO(), pool)

Expand All @@ -194,7 +203,7 @@ def test_uninstall_git_package_nspkg_pth_cleanup(mocker, tmp_venv, pool):
# in order to reproduce the scenario where the git source is removed prior to proper
# clean up of nspkg.pth file, we need to make sure the fixture is copied and not
# symlinked into the git src directory
def copy_only(source, dest):
def copy_only(source: Path, dest: Path) -> None:
if dest.exists():
dest.unlink()

Expand Down

0 comments on commit f527c3a

Please sign in to comment.