Closed ericpre closed 3 years ago
Good catch @ericpre - thanks a lot for that.
To make it more robust, I propose to change a bit the following code:
- which = "which"
+ cmd = ["which", "mamba"]
if sys.platform == "win32":
- which = "where"
+ cmd =["where", "mamba.exe"]
process = Popen(
- [which, "mamba"], stdout=PIPE, stderr=PIPE, encoding="utf-8"
+ cmd, stdout=PIPE, stderr=PIPE, encoding="utf-8"
)
So we are sure to capture an executable on Windows and not the shell script.
Regarding testing, the tests are stored in the mamba_gator/tests
folder. I would advice creating a new file for this one like test_manager.py
(it must start with test_).
Then in that file, the test functions are all function named def test_...()
. I would suggest instantiating a EnvManager
instance and test the property manager
; something like:
def test_EnvManager_manager():
try:
import mamba
except ImportError:
expected = "conda"
else:
expected = "mamba"
manager = EnvManager("", None)
assert Path(manager.manager).stem == expected
Let me known if you have questions.
Thanks, your test is god and simple! My issue was mainly with getting a EnvManager
instance working. I have tried to do something similar to https://github.com/mamba-org/gator/blob/96a711f9ef3aa03e488bd14b4322c750b5e88c55/mamba_gator/tests/test_api.py#L606-L613 for mamba and it was not working.
The following fails on windows:
with the error:
Because
output
is'C:\\Users\\Eric\\HyperSpy-bundle\\Scripts\\mamba.exe\nC:\\Users\\Eric\\HyperSpy-bundle\\condabin\\mamba.bat\n'
I have tried to add a test but I don't understand how the test suite works.