Skip to content

Commit

Permalink
Set CONDA_PREFIX in CondaEnv (#538)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tolker-KU committed Dec 27, 2021
1 parent 583a333 commit 8bb3286
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion nox/virtualenv.py
Expand Up @@ -203,7 +203,7 @@ def __init__(
self.reuse_existing = reuse_existing
self.venv_params = venv_params if venv_params else []
self.conda_cmd = conda_cmd
super().__init__()
super().__init__(env={"CONDA_PREFIX": self.location})

def _clean_location(self) -> bool:
"""Deletes existing conda environment"""
Expand Down
20 changes: 20 additions & 0 deletions tests/test_virtualenv.py
Expand Up @@ -13,7 +13,9 @@
# limitations under the License.

import os
import re
import shutil
import subprocess
import sys
from textwrap import dedent
from unittest import mock
Expand Down Expand Up @@ -246,6 +248,24 @@ def test_condaenv_(make_conda):
assert not venv.is_offline()


@pytest.mark.skipif(not HAS_CONDA, reason="Missing conda command.")
def test_condaenv_detection(make_conda):
venv, dir_ = make_conda()
venv.create()

proc_result = subprocess.run(
[py.path.local.sysfind("conda").strpath, "list"],
env=venv.env,
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
output = proc_result.stdout.decode()
path_regex = re.compile(r"packages in environment at (?P<env_dir>.+):")

assert path_regex.search(output).group("env_dir") == dir_.strpath


def test_constructor_defaults(make_one):
venv, _ = make_one()
assert venv.location
Expand Down

0 comments on commit 8bb3286

Please sign in to comment.