Repository: benchopt/benchopt (language: python)

Issue:
ENH specify channel for conda reqs
Introduce a new synthax to add a channel for conda requirements with `channel:package`.

closes #477 


Discussion / hints:

Fix patch:
diff --git a/.coveragerc b/.coveragerc
index d66f543ca..919c7cca3 100644
--- a/.coveragerc
+++ b/.coveragerc
@@ -4,7 +4,7 @@ parallel = True
 source =
     benchopt
 omit =
-    benchopt/tests/*
+    */tests/*
     setup.py
 
 [report]


Test patch:
diff --git a/benchopt/utils/tests/test_conda_env_cmd.py b/benchopt/utils/tests/test_conda_env_cmd.py
new file mode 100644
index 000000000..ef5b2d3ec
--- /dev/null
+++ b/benchopt/utils/tests/test_conda_env_cmd.py
@@ -0,0 +1,46 @@
+from benchopt.utils.conda_env_cmd import get_cmd_from_requirements
+from benchopt.config import get_setting
+
+
+CONDA_CMD = get_setting("conda_cmd")
+
+
+def test_requirements_conda():
+
+    packages = ["dep1", "dep2", "chan1:dep3"]
+    cmd = get_cmd_from_requirements(packages)
+
+    assert len(cmd) == 1
+    cmd = cmd[0]
+
+    assert CONDA_CMD in cmd, f"Should use {CONDA_CMD} to install deps."
+    assert " dep1" in cmd, f"missing dep1 in cmd: {cmd}"
+    assert " dep2" in cmd, f"missing dep2 in cmd: {cmd}"
+    assert " dep3" in cmd, f"missing dep3 in cmd: {cmd}"
+    assert " -c chan1 " in cmd, f"missing channel in cmd: {cmd}"
+
+
+def test_requirements_pip():
+
+    packages = ["pip:dep1", "pip:dep2"]
+    cmd = get_cmd_from_requirements(packages)
+
+    assert len(cmd) == 1
+    cmd = cmd[0]
+
+    assert 'pip' in cmd, "Should use pip to install deps."
+    assert " dep1" in cmd, f"missing dep1 in cmd: {cmd}"
+    assert " dep2" in cmd, f"missing dep2 in cmd: {cmd}"
+
+
+def test_requirements_mixed():
+
+    packages = ["dep1", "pip:dep2"]
+    cmd = get_cmd_from_requirements(packages)
+
+    assert len(cmd) == 2
+
+    assert CONDA_CMD in cmd[0], f"Should use {CONDA_CMD} to install dep1."
+    assert " dep1" in cmd[0], f"missing dep1 in cmd: {cmd[0]}"
+    assert 'pip ' in cmd[1], "Should use pip to install dep2."
+    assert " dep2" in cmd[1], f"missing dep2 in cmd: {cmd[1]}"