Skip to content

Commit

Permalink
Optimize tests/conftest.py (python-poetry#1271)
Browse files Browse the repository at this point in the history
- apply the PyCharm "optimize imports"
- place functions above fixtures
- alphabetize fixture functions
- remove duplicate tmp_dir fixture
  • Loading branch information
dazza-codes authored and brycedrennan committed Sep 5, 2019
1 parent 7b1e01f commit 7b13f00
Showing 1 changed file with 16 additions and 24 deletions.
40 changes: 16 additions & 24 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import httpretty
import os
import pytest
import shutil
import tempfile

import httpretty
import pytest

try:
import urllib.parse as urlparse
except ImportError:
Expand All @@ -19,15 +20,6 @@
from poetry.utils.toml_file import TomlFile


@pytest.fixture
def tmp_dir():
dir_ = tempfile.mkdtemp(prefix="poetry_")

yield dir_

shutil.rmtree(dir_)


@pytest.fixture
def config_document():
content = """cache-dir = "/foo"
Expand Down Expand Up @@ -101,13 +93,10 @@ def mock_download(self, url, dest):
os.symlink(str(fixture), str(dest))


@pytest.fixture
def tmp_dir():
dir_ = tempfile.mkdtemp(prefix="poetry_")

yield dir_

shutil.rmtree(dir_)
@pytest.fixture(autouse=True)
def download_mock(mocker):
# Patch download to not download anything but to just copy from fixtures
mocker.patch("poetry.utils.inspector.Inspector.download", new=mock_download)


@pytest.fixture
Expand All @@ -129,12 +118,6 @@ def git_mock(mocker):
p.return_value = "9cf87a285a2d3fbb0b9fa621997b3acc3631ed24"


@pytest.fixture(autouse=True)
def download_mock(mocker):
# Patch download to not download anything but to just copy from fixtures
mocker.patch("poetry.utils.inspector.Inspector.download", new=mock_download)


@pytest.fixture
def http():
httpretty.enable()
Expand All @@ -150,3 +133,12 @@ def _fixture_dir(name):
return Path(__file__).parent / "fixtures" / name

return _fixture_dir


@pytest.fixture
def tmp_dir():
dir_ = tempfile.mkdtemp(prefix="poetry_")

yield dir_

shutil.rmtree(dir_)

0 comments on commit 7b13f00

Please sign in to comment.