Skip to content

Commit

Permalink
Fix CI issues (#2069)
Browse files Browse the repository at this point in the history
  • Loading branch information
sdispater authored Feb 21, 2020
1 parent 12db4a5 commit 960dc06
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 11 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Get full python version
id: full-python-version
run: |
echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info[:3]))")
echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
- name: Install and set up Poetry
run: |
python get-poetry.py --preview -y
Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:
- name: Get full python version
id: full-python-version
run: |
echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info[:3]))")
echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
- name: Install and set up Poetry
run: |
python get-poetry.py --preview -y
Expand All @@ -87,7 +87,7 @@ jobs:
- name: Test
run: |
source $HOME/.poetry/env
poetry run pytest -q tests
.venv/bin/pytest -q tests
Windows:
needs: Linting
Expand All @@ -106,7 +106,7 @@ jobs:
id: full-python-version
shell: bash
run: |
echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info[:3]))")
echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
- name: Install and setup Poetry
run: |
python get-poetry.py --preview -y
Expand Down
4 changes: 3 additions & 1 deletion tests/console/commands/env/test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
from poetry.utils.toml_file import TomlFile


def test_none_activated(app, tmp_dir):
def test_none_activated(app, tmp_dir, mocker, env):
mocker.patch("poetry.utils.env.EnvManager.get", return_value=env)

app.poetry.config.merge({"virtualenvs": {"path": str(tmp_dir)}})

venv_name = EnvManager.generate_env_name(
Expand Down
3 changes: 3 additions & 0 deletions tests/console/commands/env/test_use.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def check_output(cmd, *args, **kwargs):


def test_activate_activates_non_existing_virtualenv_no_envs_file(app, tmp_dir, mocker):
mocker.stopall()
if "VIRTUAL_ENV" in os.environ:
del os.environ["VIRTUAL_ENV"]

Expand Down Expand Up @@ -85,6 +86,7 @@ def test_activate_activates_non_existing_virtualenv_no_envs_file(app, tmp_dir, m
def test_get_prefers_explicitly_activated_virtualenvs_over_env_var(
app, tmp_dir, mocker
):
mocker.stopall()
os.environ["VIRTUAL_ENV"] = "/environment/prefix"

venv_name = EnvManager.generate_env_name(
Expand Down Expand Up @@ -127,6 +129,7 @@ def test_get_prefers_explicitly_activated_virtualenvs_over_env_var(
def test_get_prefers_explicitly_activated_non_existing_virtualenvs_over_env_var(
app, tmp_dir, mocker
):
mocker.stopall()
os.environ["VIRTUAL_ENV"] = "/environment/prefix"

venv_name = EnvManager.generate_env_name(
Expand Down
6 changes: 1 addition & 5 deletions tests/console/commands/test_run.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
from cleo.testers import CommandTester

from poetry.utils._compat import Path
from poetry.utils.env import MockEnv


def test_run_passes_all_args(app, mocker):
env = MockEnv(path=Path("/prefix"), base=Path("/base/prefix"), is_venv=True)
def test_run_passes_all_args(app, mocker, env):
mocker.patch("poetry.utils.env.EnvManager.get", return_value=env)

command = app.find("run")
Expand Down
11 changes: 10 additions & 1 deletion tests/console/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from poetry.repositories import Repository as BaseRepository
from poetry.repositories.exceptions import PackageNotFound
from poetry.utils._compat import Path
from poetry.utils.env import MockEnv
from poetry.utils.toml_file import TomlFile
from tests.helpers import mock_clone
from tests.helpers import mock_download
Expand All @@ -28,8 +29,13 @@ def installed():
return BaseRepository()


@pytest.fixture
def env():
return MockEnv(path=Path("/prefix"), base=Path("/base/prefix"), is_venv=True)


@pytest.fixture(autouse=True)
def setup(mocker, installer, installed, config):
def setup(mocker, installer, installed, config, env):
# Set Installer's installer
p = mocker.patch("poetry.installation.installer.Installer._get_installer")
p.return_value = installer
Expand All @@ -51,6 +57,9 @@ def setup(mocker, installer, installed, config):
# Patch download to not download anything but to just copy from fixtures
mocker.patch("poetry.utils.inspector.Inspector.download", new=mock_download)

# Patch the virtual environment creation do actually do nothing
mocker.patch("poetry.utils.env.EnvManager.create_venv", return_value=env)

# Setting terminal width
environ = dict(os.environ)
os.environ["COLUMNS"] = "80"
Expand Down

0 comments on commit 960dc06

Please sign in to comment.