mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 00:14:41 +01:00
Add test for sourcing bat file on windows
This commit is contained in:
parent
ff1ee916e0
commit
7d4e5f70fc
2 changed files with 25 additions and 0 deletions
3
tests/batch.bat
Normal file
3
tests/batch.bat
Normal file
|
@ -0,0 +1,3 @@
|
|||
echo on
|
||||
set ENV_TO_BE_ADDED=Hallo world
|
||||
set ENV_TO_BE_REMOVED=
|
|
@ -8,6 +8,7 @@ import nose
|
|||
from nose.plugins.skip import SkipTest
|
||||
from nose.tools import assert_equal, assert_true, assert_false
|
||||
|
||||
from xonsh.tools import ON_WINDOWS
|
||||
from xonsh.foreign_shells import foreign_shell_data, parse_env, parse_aliases
|
||||
|
||||
def test_parse_env():
|
||||
|
@ -54,5 +55,26 @@ def test_foreign_bash_data():
|
|||
yield assert_equal, expval, obsaliases.get(key, False)
|
||||
|
||||
|
||||
def test_foreign_cmd_data():
|
||||
if not ON_WINDOWS:
|
||||
raise SkipTest
|
||||
env = (('ENV_TO_BE_REMOVED','test'),)
|
||||
batchfile = os.path.join(os.path.dirname(__file__), 'batch.bat')
|
||||
source_cmd ='call "{}"\necho off'.format(batchfile)
|
||||
try:
|
||||
obsenv, _ = foreign_shell_data('cmd',prevcmd=source_cmd,
|
||||
currenv=env,
|
||||
interactive =False,
|
||||
sourcer='call',envcmd='set',
|
||||
use_tmpfile=True,
|
||||
safe=False)
|
||||
except (subprocess.CalledProcessError, FileNotFoundError):
|
||||
raise SkipTest
|
||||
|
||||
assert_true('ENV_TO_BE_ADDED' in obsenv)
|
||||
assert_true(obsenv['ENV_TO_BE_ADDED']=='Hallo world')
|
||||
assert_true('ENV_TO_BE_REMOVED' not in obsenv)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
nose.runmodule()
|
||||
|
|
Loading…
Add table
Reference in a new issue