def test_deactivate_non_activated_but_existing( tmp_dir: str, manager: EnvManager, poetry: "Poetry", config: "Config", mocker: "MockerFixture", ): if "VIRTUAL_ENV" in os.environ: del os.environ["VIRTUAL_ENV"] venv_name = manager.generate_env_name("simple-project", str(poetry.file.parent)) python = ".".join(str(c) for c in sys.version_info[:2]) (Path(tmp_dir) / f"{venv_name}-py{python}").mkdir() config.merge({"virtualenvs": {"path": str(tmp_dir)}}) mocker.patch( "subprocess.check_output", side_effect=check_output_wrapper(), ) manager.deactivate(NullIO()) env = manager.get() assert env.path == Path(tmp_dir) / f"{venv_name}-py{python}" assert Path("/prefix")
def handle(self) -> None: from poetry.utils.env import EnvManager manager = EnvManager(self.poetry) if self.argument("python") == "system": manager.deactivate(self._io) return env = manager.activate(self.argument("python"), self._io) self.line(f"Using virtualenv: <comment>{env.path}</>")
def handle(self): from poetry.utils.env import EnvManager poetry = self.poetry manager = EnvManager(poetry.config) if self.argument("python") == "system": manager.deactivate(poetry.file.parent, self._io) return env = manager.activate(self.argument("python"), poetry.file.parent, self._io) self.line("Using virtualenv: <comment>{}</>".format(env.path))
def test_deactivate_activated( tmp_dir: str, manager: EnvManager, poetry: Poetry, config: Config, mocker: MockerFixture, ): if "VIRTUAL_ENV" in os.environ: del os.environ["VIRTUAL_ENV"] venv_name = manager.generate_env_name("simple-project", str(poetry.file.parent)) version = Version.from_parts(*sys.version_info[:3]) other_version = Version.parse( "3.4") if version.major == 2 else version.next_minor() (Path(tmp_dir) / f"{venv_name}-py{version.major}.{version.minor}").mkdir() (Path(tmp_dir) / f"{venv_name}-py{other_version.major}.{other_version.minor}").mkdir() envs_file = TOMLFile(Path(tmp_dir) / "envs.toml") doc = tomlkit.document() doc[venv_name] = { "minor": f"{other_version.major}.{other_version.minor}", "patch": other_version.text, } envs_file.write(doc) config.merge({"virtualenvs": {"path": str(tmp_dir)}}) mocker.patch( "subprocess.check_output", side_effect=check_output_wrapper(), ) manager.deactivate(NullIO()) env = manager.get() assert env.path == Path( tmp_dir) / f"{venv_name}-py{version.major}.{version.minor}" assert Path("/prefix") envs = envs_file.read() assert len(envs) == 0