diff --git a/tests/test_vox.py b/tests/test_vox.py index e03ad2c31..18d7dc4f8 100644 --- a/tests/test_vox.py +++ b/tests/test_vox.py @@ -43,3 +43,25 @@ def test_activate(xonsh_builtins, tmpdir): assert xonsh_builtins.__xonsh_env__['VIRTUAL_ENV'] == vox['spam'].env vox.deactivate() assert 'VIRTUAL_ENV' not in xonsh_builtins.__xonsh_env__ + + +@skip_if_on_conda +def test_path(xonsh_builtins, tmpdir): + """ + Test to make sure Vox properly activates and deactivates by examining $PATH + """ + xonsh_builtins.__xonsh_env__['VIRTUALENV_HOME'] = str(tmpdir) + # I consider the case that the user doesn't have a PATH set to be unreasonable + xonsh_builtins.__xonsh_env__.setdefault('PATH', []) + + oldpath = list(xonsh_builtins.__xonsh_env__['PATH']) + vox = Vox() + vox.create('eggs') + + vox.activate('eggs') + + assert oldpath != xonsh_builtins.__xonsh_env__['PATH'] + + vox.deactivate() + + assert oldpath == xonsh_builtins.__xonsh_env__['PATH'] diff --git a/xontrib/voxapi.py b/xontrib/voxapi.py index 6a3b49bed..688957d23 100644 --- a/xontrib/voxapi.py +++ b/xontrib/voxapi.py @@ -178,7 +178,7 @@ class Vox(collections.abc.Mapping): if 'VIRTUAL_ENV' in env: self.deactivate() - type(self).oldvars = {'PATH': env['PATH']} + type(self).oldvars = {'PATH': list(env['PATH'])} env['PATH'].insert(0, bin_path) env['VIRTUAL_ENV'] = env_path if 'PYTHONHOME' in env: @@ -199,6 +199,8 @@ class Vox(collections.abc.Mapping): for k, v in type(self).oldvars.items(): env[k] = v del type(self).oldvars + else: + print("Warning: No oldvars found") env.pop('VIRTUAL_ENV')