conftest.py (poetry-1.1.15) | : | conftest.py (poetry-1.2.0) | ||
---|---|---|---|---|
import shutil | from __future__ import annotations | |||
import pytest | from typing import TYPE_CHECKING | |||
from poetry.utils._compat import Path | ||||
try: | ||||
import urllib.parse as urlparse | ||||
except ImportError: | ||||
import urlparse | ||||
def mock_clone(self, source, dest): | import pytest | |||
# Checking source to determine which folder we need to copy | ||||
parts = urlparse.urlparse(source) | ||||
folder = ( | from tests.helpers import MOCK_DEFAULT_GIT_REVISION | |||
Path(__file__).parent.parent | from tests.helpers import mock_clone | |||
/ "fixtures" | ||||
/ "git" | ||||
/ parts.netloc | ||||
/ parts.path.lstrip("/").rstrip(".git") | ||||
) | ||||
shutil.rmtree(str(dest)) | if TYPE_CHECKING: | |||
shutil.copytree(str(folder), str(dest)) | from pytest_mock import MockerFixture | |||
@pytest.fixture(autouse=True) | @pytest.fixture(autouse=True) | |||
def setup(mocker): | def setup(mocker: MockerFixture) -> None: | |||
# Patch git module to not actually clone projects | # Patch git module to not actually clone projects | |||
mocker.patch("poetry.core.vcs.git.Git.clone", new=mock_clone) | mocker.patch("poetry.vcs.git.Git.clone", new=mock_clone) | |||
mocker.patch("poetry.core.vcs.git.Git.checkout", new=lambda *_: None) | p = mocker.patch("poetry.vcs.git.Git.get_revision") | |||
p = mocker.patch("poetry.core.vcs.git.Git.rev_parse") | p.return_value = MOCK_DEFAULT_GIT_REVISION | |||
p.return_value = "9cf87a285a2d3fbb0b9fa621997b3acc3631ed24" | ||||
yield | ||||
End of changes. 7 change blocks. | ||||
22 lines changed or deleted | 8 lines changed or added |