test_main.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:conda-shell 作者: gbrener 项目源码 文件源码
def test_in_shebang(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

import numpy as np
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号