-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: clean up fixtures and console tests
This change cleans up a few of the fixtures used in the test suite to be more consistent and also renames ambiguous helper classes.
- Loading branch information
Showing
22 changed files
with
571 additions
and
774 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import os | ||
|
||
import pytest | ||
|
||
from poetry.utils._compat import Path | ||
from poetry.utils.env import EnvManager | ||
|
||
|
||
@pytest.fixture | ||
def venv_name(app): | ||
return EnvManager.generate_env_name("simple-project", str(app.poetry.file.parent)) | ||
|
||
|
||
@pytest.fixture | ||
def venv_cache(tmp_dir): | ||
return Path(tmp_dir) | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def python_versions(): | ||
return ["3.6", "3.7"] | ||
|
||
|
||
@pytest.fixture | ||
def venvs_in_cache_config(app, venv_cache): | ||
app.poetry.config.merge({"virtualenvs": {"path": str(venv_cache)}}) | ||
|
||
|
||
@pytest.fixture | ||
def venvs_in_cache_dirs( | ||
app, venvs_in_cache_config, venv_name, venv_cache, python_versions | ||
): | ||
directories = [] | ||
for version in python_versions: | ||
directory = venv_cache.joinpath("{}-py{}".format(venv_name, version)) | ||
directory.mkdir(parents=True, exist_ok=True) | ||
directories.append(directory.name) | ||
return directories | ||
|
||
|
||
@pytest.fixture | ||
def venvs_in_project_dir(app): | ||
os.environ.pop("VIRTUAL_ENV", None) | ||
venv_dir = app.poetry.file.parent.joinpath(".venv") | ||
venv_dir.mkdir(exist_ok=True) | ||
app.poetry.config.merge({"virtualenvs": {"in-project": True}}) | ||
|
||
try: | ||
yield venv_dir | ||
finally: | ||
venv_dir.rmdir() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from typing import Optional | ||
from typing import Union | ||
|
||
from poetry.core.semver import Version | ||
from poetry.utils._compat import Path | ||
|
||
|
||
def build_venv(path, executable=None): # type: (Union[Path,str], Optional[str]) -> () | ||
Path(path).mkdir(parents=True, exist_ok=True) | ||
|
||
|
||
def check_output_wrapper(version=Version.parse("3.7.1")): | ||
def check_output(cmd, *args, **kwargs): | ||
if "sys.version_info[:3]" in cmd: | ||
return version.text | ||
elif "sys.version_info[:2]" in cmd: | ||
return "{}.{}".format(version.major, version.minor) | ||
else: | ||
return str(Path("/prefix")) | ||
|
||
return check_output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.