Repository: ESSS/conda-devenv

Issue:
0.9.3 broken: no longer generates activate/deactivate scripts
#46 introduced a bug: `conda-devenv` now calls `conda_env.main` directly, which probably calls `sys.exit()`, which skips activate/deactivate scripts generation.

Discussion:

Patch:
diff --git a/HISTORY.rst b/HISTORY.rst
index 608aaa0..f9fafd4 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -3,6 +3,12 @@ History
 =======
 
 
+0.9.5 (2017-04-24)
+------------------
+
+* Handle ``None`` correctly, which actually fixes (`#49`_).
+
+
 0.9.4 (2017-04-20)
 ------------------
 
diff --git a/conda_devenv/devenv.py b/conda_devenv/devenv.py
index 16d174c..44df72e 100644
--- a/conda_devenv/devenv.py
+++ b/conda_devenv/devenv.py
@@ -373,7 +373,7 @@ def main(args=None):
 
     # Call conda-env update
     retcode = __call_conda_env_update(args, output_filename)
-    if retcode != 0:
+    if retcode:
         return retcode
 
     if is_devenv_input_file:


Test patch:
diff --git a/tests/test_main.py b/tests/test_main.py
index 4f0db10..feb2425 100644
--- a/tests/test_main.py
+++ b/tests/test_main.py
@@ -21,16 +21,20 @@ def patch_conda_calls(mocker):
     ('environment.devenv.yml', 1),
     ('environment.yml', 0),
 ])
+@pytest.mark.parametrize('return_none', [True, False])
 @pytest.mark.usefixtures('patch_conda_calls')
-def test_handle_input_file(tmpdir, input_name, write_scripts_call_count):
+def test_handle_input_file(tmpdir, input_name, write_scripts_call_count, return_none):
     """
     Test how conda-devenv handles input files: devenv.yml and pure .yml files.
     """
     argv = []
     def call_conda_mock():
         argv[:] = sys.argv[:]
-        # simulate that we actually called conda's main, which calls sys.exit()
-        sys.exit(0)
+        # conda's env main() function sometimes returns None and other times raises SystemExit
+        if return_none:
+            return None
+        else:
+            sys.exit(0)
 
     devenv._call_conda.side_effect = call_conda_mock