helpers.py 文件源码

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

项目:whaaaaat 作者: finklabs 项目源码 文件源码
def create_example_fixture(example):
    """Create a pytest fixture to run the example in pty subprocess & cleanup.

    :param example: relative path like 'examples/input.py'
    :return: pytest fixture
    """
    @pytest.fixture
    def example_app():
        p = SimplePty.spawn(['python', example])
        yield p
        # it takes some time to collect the coverage data
        # if the main process exits too early the coverage data is not available
        time.sleep(p.delayafterterminate)
        p.sendintr()  # in case the subprocess was not ended by the test
        p.wait()  # without wait() the coverage info never arrives
    return example_app
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号