Forgot to copy a mutated value on save. Added a test to prevent
regression.
This commit is contained in:
Jamie Bliss 2016-07-30 03:35:39 -04:00
parent 1034612eca
commit 9d727652c7
2 changed files with 25 additions and 1 deletions

View file

@ -43,3 +43,25 @@ def test_activate(xonsh_builtins, tmpdir):
assert xonsh_builtins.__xonsh_env__['VIRTUAL_ENV'] == vox['spam'].env assert xonsh_builtins.__xonsh_env__['VIRTUAL_ENV'] == vox['spam'].env
vox.deactivate() vox.deactivate()
assert 'VIRTUAL_ENV' not in xonsh_builtins.__xonsh_env__ 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']

View file

@ -178,7 +178,7 @@ class Vox(collections.abc.Mapping):
if 'VIRTUAL_ENV' in env: if 'VIRTUAL_ENV' in env:
self.deactivate() self.deactivate()
type(self).oldvars = {'PATH': env['PATH']} type(self).oldvars = {'PATH': list(env['PATH'])}
env['PATH'].insert(0, bin_path) env['PATH'].insert(0, bin_path)
env['VIRTUAL_ENV'] = env_path env['VIRTUAL_ENV'] = env_path
if 'PYTHONHOME' in env: if 'PYTHONHOME' in env:
@ -199,6 +199,8 @@ class Vox(collections.abc.Mapping):
for k, v in type(self).oldvars.items(): for k, v in type(self).oldvars.items():
env[k] = v env[k] = v
del type(self).oldvars del type(self).oldvars
else:
print("Warning: No oldvars found")
env.pop('VIRTUAL_ENV') env.pop('VIRTUAL_ENV')