summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/changelog/1842.feature.rst2
-rw-r--r--src/tox/tox_env/python/virtual_env/api.py11
-rw-r--r--tests/tox_env/python/virtual_env/test_virtualenv_api.py10
3 files changed, 20 insertions, 3 deletions
diff --git a/docs/changelog/1842.feature.rst b/docs/changelog/1842.feature.rst
new file mode 100644
index 00000000..e12296f6
--- /dev/null
+++ b/docs/changelog/1842.feature.rst
@@ -0,0 +1,2 @@
+Add support for the ``list_dependencies_command`` settings in the virtual env test environments - by
+:user:`gaborbernat`.
diff --git a/src/tox/tox_env/python/virtual_env/api.py b/src/tox/tox_env/python/virtual_env/api.py
index ac0902cf..e1a75057 100644
--- a/src/tox/tox_env/python/virtual_env/api.py
+++ b/src/tox/tox_env/python/virtual_env/api.py
@@ -67,7 +67,6 @@ class VirtualEnv(Python, ABC):
default=False,
desc="install the latest available pre-release (alpha/beta/rc) of dependencies without a specified version",
)
-
self.conf.add_config(
keys=["install_command"],
of_type=Command,
@@ -75,6 +74,12 @@ class VirtualEnv(Python, ABC):
post_process=self.post_process_install_command,
desc="install the latest available pre-release (alpha/beta/rc) of dependencies without a specified version",
)
+ self.conf.add_config(
+ keys=["list_dependencies_command"],
+ of_type=Command,
+ default=Command(["python", "-m", "pip", "freeze", "--all"]),
+ desc="install the latest available pre-release (alpha/beta/rc) of dependencies without a specified version",
+ )
def post_process_install_command(self, cmd: Command) -> Command:
install_command = cmd.args
@@ -218,9 +223,9 @@ class VirtualEnv(Python, ABC):
)
def get_installed_packages(self) -> List[str]:
- list_command = [self.creator.exe, "-I", "-m", "pip", "freeze", "--all"]
+ cmd: Command = self.conf["list_dependencies_command"]
result = self.execute(
- cmd=list_command,
+ cmd=cmd.args,
stdin=StdinSource.OFF,
run_id="freeze",
show=self.options.verbosity > DEFAULT_VERBOSITY,
diff --git a/tests/tox_env/python/virtual_env/test_virtualenv_api.py b/tests/tox_env/python/virtual_env/test_virtualenv_api.py
index 0a406596..1fe07ebc 100644
--- a/tests/tox_env/python/virtual_env/test_virtualenv_api.py
+++ b/tests/tox_env/python/virtual_env/test_virtualenv_api.py
@@ -145,3 +145,13 @@ def test_install_command_no_packages(
request: ExecuteRequest = execute_calls.call_args[0][3]
found_cmd = request.cmd
assert found_cmd[:-1] == ["python", "-m", "pip", "install", "-i", disable_pip_pypi_access[0], "--pre", "-r"]
+
+
+def test_list_dependencies_command(tox_project: ToxProjectCreator, monkeypatch: MonkeyPatch) -> None:
+ install_cmd = "python -m pip freeze"
+ proj = tox_project({"tox.ini": f"[testenv]\npackage=skip\nlist_dependencies_command={install_cmd}"})
+ execute_calls = proj.patch_execute(lambda r: 0 if "install" in r.run_id else None)
+ result = proj.run("r", "--result-json", str(proj.path / "out.json"))
+ result.assert_success()
+ request: ExecuteRequest = execute_calls.call_args[0][3]
+ assert request.cmd == ["python", "-m", "pip", "freeze"]