mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
Fix #1513
Forgot to copy a mutated value on save. Added a test to prevent regression.
This commit is contained in:
parent
1034612eca
commit
9d727652c7
2 changed files with 25 additions and 1 deletions
|
@ -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']
|
||||
|
|
|
@ -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')
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue