mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
revert context thing
This commit is contained in:
parent
ad48cd23ec
commit
c09c1af77b
2 changed files with 1 additions and 23 deletions
|
@ -14,22 +14,6 @@ def mockopen(xonsh_builtins, monkeypatch):
|
|||
monkeypatch.setattr(builtins, 'open', mocked_open)
|
||||
|
||||
|
||||
def test_source_context(mockopen, monkeypatch):
|
||||
checker = []
|
||||
|
||||
def mocked_execx(src, *args, **kwargs):
|
||||
checker.append(src.strip())
|
||||
monkeypatch.setattr(builtins, 'execx', mocked_execx)
|
||||
monkeypatch.setattr(os.path, 'isfile', lambda x: True)
|
||||
ctx = builtins.__xonsh_ctx__
|
||||
ctx['foo'] = 'ctx_foo'
|
||||
ctx['bar'] = 'ctx_bar'
|
||||
|
||||
source_alias(['foo', 'bar'])
|
||||
assert checker[0].endswith('ctx_foo')
|
||||
assert checker[1].endswith('ctx_bar')
|
||||
|
||||
|
||||
def test_source_current_dir(mockopen, monkeypatch):
|
||||
checker = []
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ from xonsh.proc import foreground
|
|||
from xonsh.replay import replay_main
|
||||
from xonsh.timings import timeit_alias
|
||||
from xonsh.tools import argvquote, escape_windows_cmd_string, to_bool
|
||||
from xonsh.tools import expanduser_abs_path
|
||||
from xonsh.xontribs import xontribs_main
|
||||
|
||||
import xonsh.completers._aliases as xca
|
||||
|
@ -253,16 +252,11 @@ def source_alias(args, stdin=None):
|
|||
If sourced file isn't found in cwd, search for file along $PATH to source
|
||||
instead.
|
||||
"""
|
||||
ctx = builtins.__xonsh_ctx__
|
||||
env = builtins.__xonsh_env__
|
||||
encoding = env.get('XONSH_ENCODING')
|
||||
errors = env.get('XONSH_ENCODING_ERRORS')
|
||||
for fname in args:
|
||||
fpath = fname
|
||||
if fname in ctx:
|
||||
file_ctx = expanduser_abs_path(ctx[fname])
|
||||
if os.path.isfile(file_ctx):
|
||||
fpath = file_ctx
|
||||
if not os.path.isfile(fpath):
|
||||
fpath = locate_binary(fname)
|
||||
if fpath is None:
|
||||
|
@ -272,7 +266,7 @@ def source_alias(args, stdin=None):
|
|||
src = fp.read()
|
||||
if not src.endswith('\n'):
|
||||
src += '\n'
|
||||
builtins.execx(src, 'exec', ctx)
|
||||
builtins.execx(src, 'exec', builtins.__xonsh_ctx__)
|
||||
|
||||
|
||||
def source_cmd(args, stdin=None):
|
||||
|
|
Loading…
Add table
Reference in a new issue