def test_repath_backslash(): home = os.path.expanduser('~') exp = os.listdir(home) exp = {p for p in exp if re.match(r'\w\w.*', p)} exp = {os.path.join(home, p) for p in exp} obs = set(regexpath(r'~/\w\w.*')) assert_equal(exp, obs)
def test_repath_home_var_brace(): exp = os.path.expanduser('~') built_ins.ENV = Env(HOME=exp) obs = regexpath('${HOME}') assert_equal(1, len(os.environ)) built_ins.ENV.undo_replace_env() assert_equal(1, len(obs)) assert_equal(exp, obs[0])
def test_repath_home_var(): exp = os.path.expanduser("~") built_ins.ENV = Env(HOME=exp) obs = regexpath("$HOME") assert_equal(1, len(os.environ)) built_ins.ENV.undo_replace_env() assert_equal(1, len(obs)) assert_equal(exp, obs[0])
def test_repath_home_var_brace(): if ON_WINDOWS: raise SkipTest exp = os.path.expanduser('~') built_ins.ENV = Env(HOME=exp) with mock_xonsh_env(built_ins.ENV): obs = regexpath('${"HOME"}') assert_equal(1, len(obs)) assert_equal(exp, obs[0])
def test_repath_backslash(): if ON_WINDOWS: raise SkipTest home = os.path.expanduser("~") exp = os.listdir(home) exp = {p for p in exp if re.match(r"\w\w.*", p)} exp = {os.path.join(home, p) for p in exp} obs = set(regexpath(r"~/\w\w.*")) assert_equal(exp, obs)
def test_repath_home_contents(): if ON_WINDOWS: raise SkipTest home = os.path.expanduser('~') built_ins.ENV = Env(HOME=home) with mock_xonsh_env(built_ins.ENV): exp = os.listdir(home) exp = {os.path.join(home, p) for p in exp} obs = set(regexpath('~/.*')) assert_equal(exp, obs)
def test_repath_backslash(): if ON_WINDOWS: raise SkipTest home = os.path.expanduser('~') built_ins.ENV = Env(HOME=home) with mock_xonsh_env(built_ins.ENV): exp = os.listdir(home) exp = {p for p in exp if re.match(r'\w\w.*', p)} exp = {os.path.join(home, p) for p in exp} obs = set(regexpath(r'~/\w\w.*')) assert_equal(exp, obs)
def test_repath_home_contents(): home = os.path.expanduser('~') exp = os.listdir(home) exp = {os.path.join(home, p) for p in exp} obs = set(regexpath('~/.*')) assert_equal(exp, obs)
def test_repath_home_itself(): exp = os.path.expanduser('~') obs = regexpath('~') assert_equal(1, len(obs)) assert_equal(exp, obs[0])