def test_in_shebang_multiline(self, remove_shell_envs, capfd):
"""Test that conda-shell works from within a shebang line."""
tempfd = tempfile.NamedTemporaryFile(mode='w', delete=False)
tempfd.write('''#!/usr/bin/env conda-shell
#!conda-shell -i python python=3.6 numpy=1.12
#!conda-shell -c conda-forge pandas pydap
import numpy as np
import pandas as pd
import pydap
print(f\'np.arange(10): {np.arange(10)}\')
''')
tempfd.flush()
tempfd.close()
stats = os.stat(tempfd.name)
os.chmod(tempfd.name, stats.st_mode | stat.S_IEXEC)
subprocess.check_call([tempfd.name],
universal_newlines=True,
env=remove_shell_envs)
out, err = capfd.readouterr()
assert 'np.arange(10): [0 1 2 3 4 5 6 7 8 9]' in out+err
评论列表
文章目录