Skip to content

Commit

Permalink
Fix VIRTUALENV_PYTHON environment lookup
Browse files Browse the repository at this point in the history
The previous change which introduced the fallback discovery (pypa#1995)
broke this behaviour.
  • Loading branch information
pneff committed Oct 28, 2020
1 parent 0a5009a commit 4c3e4e2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/virtualenv/discovery/builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def add_parser_arguments(cls, parser):
"--python",
dest="python",
metavar="py",
type=str,
action="append",
default=[],
help="interpreter based on what to create environment (path/identifier) "
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/config/test_env_var.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import pytest

from virtualenv.config.cli.parser import VirtualEnvOptions
from virtualenv.config.ini import IniConfig
from virtualenv.run import session_via_cli
from virtualenv.util.path import Path
Expand Down Expand Up @@ -31,6 +32,13 @@ def test_value_bad(monkeypatch, caplog, empty_conf):
assert "invalid literal" in caplog.messages[0]


def test_python_via_env_var(monkeypatch):
options = VirtualEnvOptions()
monkeypatch.setenv(str("VIRTUALENV_PYTHON"), str("python3"))
session_via_cli(["venv"], options=options)
assert options.python == ["python3"]


def test_extra_search_dir_via_env_var(tmp_path, monkeypatch):
monkeypatch.chdir(tmp_path)
value = "a{}0{}b{}c".format(os.linesep, os.linesep, os.pathsep)
Expand Down

0 comments on commit 4c3e4e2

Please sign in to comment.