Skip to content

Commit

Permalink
fix conda#6592 deactivate command order
Browse files Browse the repository at this point in the history
  • Loading branch information
kalefranz committed Dec 28, 2017
1 parent fbf3c0d commit 1cf2b2b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions conda/activate.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ class Help(CondaError): # NOQA
self.command = command

def _yield_commands(self, cmds_dict):
for script in cmds_dict.get('deactivate_scripts', ()):
yield self.run_script_tmpl % script

for key in sorted(cmds_dict.get('unset_vars', ())):
yield self.unset_var_tmpl % key

Expand All @@ -196,9 +199,6 @@ def _yield_commands(self, cmds_dict):
for key, value in sorted(iteritems(cmds_dict.get('export_vars', {}))):
yield self.export_var_tmpl % (key, value)

for script in cmds_dict.get('deactivate_scripts', ()):
yield self.run_script_tmpl % script

for script in cmds_dict.get('activate_scripts', ()):
yield self.run_script_tmpl % script

Expand Down
24 changes: 12 additions & 12 deletions tests/test_activate.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,9 @@ def test_posix_basic(self):
reactivate_data = c.stdout

assert reactivate_data == dals("""
. "%(deactivate1)s"
export CONDA_PROMPT_MODIFIER='(%(native_prefix)s) '
export CONDA_SHLVL='1'
. "%(deactivate1)s"
. "%(activate1)s"
""") % {
'activate1': activator.path_conversion(join(self.prefix, 'etc', 'conda', 'activate.d', 'activate1.sh')),
Expand All @@ -464,14 +464,14 @@ def test_posix_basic(self):

new_path = activator.pathsep_join(activator._remove_prefix_from_path(self.prefix))
assert deactivate_data == dals("""
. "%(deactivate1)s"
unset CONDA_DEFAULT_ENV
unset CONDA_PREFIX
unset CONDA_PROMPT_MODIFIER
unset CONDA_PYTHON_EXE
PS1='%(ps1)s'
export CONDA_SHLVL='0'
export PATH='%(new_path)s'
. "%(deactivate1)s"
""") % {
'new_path': new_path,
'deactivate1': activator.path_conversion(join(self.prefix, 'etc', 'conda', 'deactivate.d', 'deactivate1.sh')),
Expand Down Expand Up @@ -524,9 +524,9 @@ def test_cmd_exe_basic(self):
rm_rf(reactivate_result)

assert reactivate_data == dals("""
@CALL "%(deactivate1)s"
@SET "CONDA_PROMPT_MODIFIER=(%(native_prefix)s) "
@SET "CONDA_SHLVL=1"
@CALL "%(deactivate1)s"
@CALL "%(activate1)s"
""") % {
'activate1': activator.path_conversion(join(self.prefix, 'etc', 'conda', 'activate.d', 'activate1.bat')),
Expand All @@ -545,13 +545,13 @@ def test_cmd_exe_basic(self):

new_path = activator.pathsep_join(activator._remove_prefix_from_path(self.prefix))
assert deactivate_data == dals("""
@CALL "%(deactivate1)s"
@SET CONDA_DEFAULT_ENV=
@SET CONDA_PREFIX=
@SET CONDA_PROMPT_MODIFIER=
@SET CONDA_PYTHON_EXE=
@SET "CONDA_SHLVL=0"
@SET "PATH=%(new_path)s"
@CALL "%(deactivate1)s"
""") % {
'new_path': new_path,
'deactivate1': activator.path_conversion(join(self.prefix, 'etc', 'conda', 'deactivate.d', 'deactivate1.bat')),
Expand Down Expand Up @@ -598,9 +598,9 @@ def test_csh_basic(self):
reactivate_data = c.stdout

assert reactivate_data == dals("""
source "%(deactivate1)s";
setenv CONDA_PROMPT_MODIFIER "(%(native_prefix)s) ";
setenv CONDA_SHLVL "1";
source "%(deactivate1)s";
source "%(activate1)s";
""") % {
'activate1': activator.path_conversion(join(self.prefix, 'etc', 'conda', 'activate.d', 'activate1.csh')),
Expand All @@ -616,14 +616,14 @@ def test_csh_basic(self):

new_path = activator.pathsep_join(activator._remove_prefix_from_path(self.prefix))
assert deactivate_data == dals("""
source "%(deactivate1)s";
unset CONDA_DEFAULT_ENV;
unset CONDA_PREFIX;
unset CONDA_PROMPT_MODIFIER;
unset CONDA_PYTHON_EXE;
set prompt='%(prompt)s';
setenv CONDA_SHLVL "0";
setenv PATH "%(new_path)s";
source "%(deactivate1)s";
""") % {
'new_path': new_path,
'deactivate1': activator.path_conversion(join(self.prefix, 'etc', 'conda', 'deactivate.d', 'deactivate1.csh')),
Expand Down Expand Up @@ -676,9 +676,9 @@ def test_xonsh_basic(self):
rm_rf(reactivate_result)

assert reactivate_data == dals("""
source "%(deactivate1)s"
$CONDA_PROMPT_MODIFIER = '(%(native_prefix)s) '
$CONDA_SHLVL = '1'
source "%(deactivate1)s"
source "%(activate1)s"
""") % {
'activate1': activator.path_conversion(join(self.prefix, 'etc', 'conda', 'activate.d', 'activate1.xsh')),
Expand All @@ -697,13 +697,13 @@ def test_xonsh_basic(self):

new_path = activator.pathsep_join(activator._remove_prefix_from_path(self.prefix))
assert deactivate_data == dals("""
source "%(deactivate1)s"
del $CONDA_DEFAULT_ENV
del $CONDA_PREFIX
del $CONDA_PROMPT_MODIFIER
del $CONDA_PYTHON_EXE
$CONDA_SHLVL = '0'
$PATH = '%(new_path)s'
source "%(deactivate1)s"
""") % {
'new_path': new_path,
'deactivate1': activator.path_conversion(join(self.prefix, 'etc', 'conda', 'deactivate.d', 'deactivate1.xsh')),
Expand Down Expand Up @@ -748,9 +748,9 @@ def test_fish_basic(self):
reactivate_data = c.stdout

assert reactivate_data == dals("""
source "%(deactivate1)s";
set -gx CONDA_PROMPT_MODIFIER "(%(native_prefix)s) ";
set -gx CONDA_SHLVL "1";
source "%(deactivate1)s";
source "%(activate1)s";
""") % {
'activate1': activator.path_conversion(join(self.prefix, 'etc', 'conda', 'activate.d', 'activate1.fish')),
Expand All @@ -766,13 +766,13 @@ def test_fish_basic(self):

new_path = activator.pathsep_join(activator._remove_prefix_from_path(self.prefix))
assert deactivate_data == dals("""
source "%(deactivate1)s";
set -e CONDA_DEFAULT_ENV;
set -e CONDA_PREFIX;
set -e CONDA_PROMPT_MODIFIER;
set -e CONDA_PYTHON_EXE;
set -gx CONDA_SHLVL "0";
set -gx PATH "%(new_path)s";
source "%(deactivate1)s";
""") % {
'new_path': new_path,
'deactivate1': activator.path_conversion(join(self.prefix, 'etc', 'conda', 'deactivate.d', 'deactivate1.fish')),
Expand Down Expand Up @@ -817,9 +817,9 @@ def test_powershell_basic(self):
reactivate_data = c.stdout

assert reactivate_data == dals("""
. "%(deactivate1)s"
$env:CONDA_PROMPT_MODIFIER = "(%(prefix)s) "
$env:CONDA_SHLVL = "1"
. "%(deactivate1)s"
. "%(activate1)s"
""") % {
'activate1': join(self.prefix, 'etc', 'conda', 'activate.d', 'activate1.ps1'),
Expand All @@ -835,13 +835,13 @@ def test_powershell_basic(self):

new_path = activator.pathsep_join(activator._remove_prefix_from_path(self.prefix))
assert deactivate_data == dals("""
. "%(deactivate1)s"
Remove-Variable CONDA_DEFAULT_ENV
Remove-Variable CONDA_PREFIX
Remove-Variable CONDA_PROMPT_MODIFIER
Remove-Variable CONDA_PYTHON_EXE
$env:CONDA_SHLVL = "0"
$env:PATH = "%(new_path)s"
. "%(deactivate1)s"
""") % {
'new_path': new_path,
'deactivate1': join(self.prefix, 'etc', 'conda', 'deactivate.d', 'deactivate1.ps1'),
Expand Down

0 comments on commit 1cf2b2b

Please sign in to comment.