diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fd09899b96d..cb541c562b7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/tests/console/commands/env/test_list.py b/tests/console/commands/env/test_list.py index 1d79b8e57a7..e9112449307 100644 --- a/tests/console/commands/env/test_list.py +++ b/tests/console/commands/env/test_list.py @@ -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( diff --git a/tests/console/commands/env/test_use.py b/tests/console/commands/env/test_use.py index 7f848494755..2b1967bf3b1 100644 --- a/tests/console/commands/env/test_use.py +++ b/tests/console/commands/env/test_use.py @@ -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"] @@ -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( @@ -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( diff --git a/tests/console/commands/test_run.py b/tests/console/commands/test_run.py index 45848222841..e8ae40aa606 100644 --- a/tests/console/commands/test_run.py +++ b/tests/console/commands/test_run.py @@ -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") diff --git a/tests/console/conftest.py b/tests/console/conftest.py index 6750fbbcfdd..58b8834aa61 100644 --- a/tests/console/conftest.py +++ b/tests/console/conftest.py @@ -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 @@ -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 @@ -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"