@pytest.mark.parametrize('inp, exp', [('foo', 'foo'), ('$foo $bar', 'bar $bar'), ('$foobar', '$foobar'), ('$foo $spam', 'bar eggs'), ('$an_int$spam$a_bool', '42eggsTrue'), ('bar$foo$spam$foo $an_int $none', 'barbareggsbar 42 None'), ('$foo/bar', 'bar/bar'), ("${'foo'} $spam", 'bar eggs'), ("${'foo'} ${'a_bool'}", 'bar True'), ("${'foo'}bar", 'barbar'), ("${'foo'}/bar", 'bar/bar'), ('${"foo\'}', '${"foo\'}'), ('$?bar', '$?bar'), ('$foo}bar', 'bar}bar'), ("${'foo", "${'foo"), skip_if_on_unix(('%foo%bar', 'barbar')), skip_if_on_unix(('%foo% %a_bool%', 'bar True')), skip_if_on_unix(('%foo%%an_int%', 'bar42')), skip_if_on_unix(("%foo% $spam ${'a_bool'}", 'bar eggs True')), ('foo', 'foo'), ('$foo bar', 'bar bar'), ("${'foo'}bar", 'barbar'), skip_if_on_unix(('%foo%bar', 'barbar'))])
def test_expandvars(inp, exp, xonsh_builtins):
 env = Env({'foo': 'bar', 'spam': 'eggs', 'a_bool': True, 'an_int': 42, 'none': None})
 xonsh_builtins.__xonsh_env__ = env
 assert (expandvars(inp) == exp)

@ pytest . mark . parametrize ( 'inp, exp' , [ ( 'foo' , 'foo' ) , ( '$foo $bar' , 'bar $bar' ) , ( '$foobar' , '$foobar' ) , ( '$foo $spam' , 'bar eggs' ) , ( '$an_int$spam$a_bool' , '42eggsTrue' ) , ( 'bar$foo$spam$foo $an_int $none' , 'barbareggsbar 42 None' ) , ( '$foo/bar' , 'bar/bar' ) , ( "${'foo'} $spam" , 'bar eggs' ) , ( "${'foo'} ${'a_bool'}" , 'bar True' ) , ( "${'foo'}bar" , 'barbar' ) , ( "${'foo'}/bar" , 'bar/bar' ) , ( '${"foo\'}' , '${"foo\'}' ) , ( '$?bar' , '$?bar' ) , ( '$foo}bar' , 'bar}bar' ) , ( "${'foo" , "${'foo" ) , skip_if_on_unix ( ( '%foo%bar' , 'barbar' ) ) , skip_if_on_unix ( ( '%foo% %a_bool%' , 'bar True' ) ) , skip_if_on_unix ( ( '%foo%%an_int%' , 'bar42' ) ) , skip_if_on_unix ( ( "%foo% $spam ${'a_bool'}" , 'bar eggs True' ) ) , ( 'foo' , 'foo' ) , ( '$foo bar' , 'bar bar' ) , ( "${'foo'}bar" , 'barbar' ) , skip_if_on_unix ( ( '%foo%bar' , 'barbar' ) ) ] ) def test_expandvars ( inp , exp , xonsh_builtins ) : env = Env ( { 'foo' : 'bar' , 'spam' : 'eggs' , 'a_bool' : True , 'an_int' : 42 , 'none' : None } ) xonsh_builtins . __xonsh_env__ = env assert ( expandvars ( inp ) == exp )
tweaked for xonsh cases from cpython test_genericpath .