def test_expandvars(inp, exp, xonsh_builtins): """Tweaked for xonsh cases from CPython `test_genericpath.py`""" env = Env( {"foo": "bar", "spam": "eggs", "a_bool": True, "an_int": 42, "none": None} ) xonsh_builtins.__xonsh__.env = env assert expandvars(inp) == exp
def test_expandvars(inp, exp, xonsh_builtins): """Tweaked for xonsh cases from CPython `test_genericpath.py`""" env = Env({ 'foo': 'bar', 'spam': 'eggs', 'a_bool': True, 'an_int': 42, 'none': None }) xonsh_builtins.__xonsh_env__ = env assert expandvars(inp) == exp
def expand_path(s): """Takes a string path and expands ~ to home and environment vars.""" if builtins.__xonsh_env__.get('EXPAND_ENV_VARS'): s = expandvars(s) # expand ~ according to Bash unquoted rules "Each variable assignment is # checked for unquoted tilde-prefixes immediately following a ':' or the # first '='". See the following for more details. # https://www.gnu.org/software/bash/manual/html_node/Tilde-Expansion.html pre, char, post = s.partition('=') s = pre + char + os.path.expanduser(post) if char else s s = os.pathsep.join(map(os.path.expanduser, s.split(os.pathsep))) return s
def expand_path(s): """Takes a string path and expands ~ to home and environment vars.""" if builtins.__xonsh_env__.get('EXPAND_ENV_VARS'): s = expandvars(s) # expand ~ according to Bash unquoted rules "Each variable assignment is # checked for unquoted tilde-prefixes immediately following a ':' or the # first '='". See the following for more details. # https://www.gnu.org/software/bash/manual/html_node/Tilde-Expansion.html pre, char, post = s.partition('=') if char: s = os.path.expanduser(pre) + char s += os.pathsep.join(map(os.path.expanduser, post.split(os.pathsep))) else: s = os.path.expanduser(s) return s
def expand_path(s): """Takes a string path and expands ~ to home and environment vars.""" if builtins.__xonsh_env__.get('EXPAND_ENV_VARS'): s = expandvars(s) return os.path.expanduser(s)
def expand_path(s): """Takes a string path and expands ~ to home and environment vars.""" global ENV if ENV.get('EXPAND_ENV_VARS'): s = expandvars(s) return os.path.expanduser(s)
def test_expandvars(inp, exp, xession): """Tweaked for xonsh cases from CPython `test_genericpath.py`""" xession.env.update( dict({"foo": "bar", "spam": "eggs", "a_bool": True, "an_int": 42, "none": None}) ) assert expandvars(inp) == exp
def test_expandvars(inp, exp, xonsh_builtins): """Tweaked for xonsh cases from CPython `test_genericpath.py`""" env = Env({'foo':'bar', 'spam': 'eggs', 'a_bool': True, 'an_int': 42, 'none': None}) xonsh_builtins.__xonsh_env__ = env assert expandvars(inp) == exp