2015-02-11 02:01:35 -06:00
|
|
|
"""Tests the xonsh lexer."""
|
|
|
|
from __future__ import unicode_literals, print_function
|
|
|
|
import builtins
|
|
|
|
import subprocess
|
2015-02-25 00:46:11 -06:00
|
|
|
import glob
|
2015-02-11 02:01:35 -06:00
|
|
|
from contextlib import contextmanager
|
|
|
|
|
2015-03-28 17:55:48 -05:00
|
|
|
from xonsh.built_ins import ensure_list_of_strs
|
|
|
|
|
2015-02-24 21:58:37 -06:00
|
|
|
def sp(cmd):
|
|
|
|
return subprocess.check_output(cmd, universal_newlines=True)
|
|
|
|
|
2015-02-11 02:01:35 -06:00
|
|
|
@contextmanager
|
|
|
|
def mock_xonsh_env(xenv):
|
|
|
|
builtins.__xonsh_env__ = xenv
|
|
|
|
builtins.__xonsh_help__ = lambda x: x
|
2015-02-25 00:46:11 -06:00
|
|
|
builtins.__xonsh_glob__ = glob.glob
|
2015-03-01 21:23:01 -06:00
|
|
|
builtins.__xonsh_exit__ = False
|
2015-02-11 02:01:35 -06:00
|
|
|
builtins.__xonsh_superhelp__ = lambda x: x
|
|
|
|
builtins.__xonsh_regexpath__ = lambda x: []
|
2015-02-24 21:58:37 -06:00
|
|
|
builtins.__xonsh_subproc_captured__ = sp
|
|
|
|
builtins.__xonsh_subproc_uncaptured__ = sp
|
2015-03-28 17:55:48 -05:00
|
|
|
builtins.__xonsh_ensure_list_of_strs__ = ensure_list_of_strs
|
2015-02-28 16:10:34 -06:00
|
|
|
builtins.evalx = None
|
|
|
|
builtins.execx = None
|
|
|
|
builtins.compilex = None
|
|
|
|
builtins.aliases = {}
|
2015-02-11 02:01:35 -06:00
|
|
|
yield
|
|
|
|
del builtins.__xonsh_env__
|
|
|
|
del builtins.__xonsh_help__
|
2015-02-25 00:46:11 -06:00
|
|
|
del builtins.__xonsh_glob__
|
2015-03-01 21:23:01 -06:00
|
|
|
del builtins.__xonsh_exit__
|
2015-02-11 02:01:35 -06:00
|
|
|
del builtins.__xonsh_superhelp__
|
|
|
|
del builtins.__xonsh_regexpath__
|
2015-02-24 21:58:37 -06:00
|
|
|
del builtins.__xonsh_subproc_captured__
|
|
|
|
del builtins.__xonsh_subproc_uncaptured__
|
2015-03-28 17:55:48 -05:00
|
|
|
del builtins.__xonsh_ensure_list_of_strs__
|
2015-02-28 16:10:34 -06:00
|
|
|
del builtins.evalx
|
|
|
|
del builtins.execx
|
|
|
|
del builtins.compilex
|
|
|
|
del builtins.aliases
|
2015-02-11 02:01:35 -06:00
|
|
|
|