test_params.py 文件源码

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

项目:pytest-github 作者: jlaska 项目源码 文件源码
def test_param_broken_cfg(testdir, content):
    '''verifies pytest-github loads completed info from provided --github-cfg parameter'''

    # create github.yml config for testing

    with mock.patch('os.path.isfile', return_value=True) as mock_isfile:
        with mock.patch('pytest_github.plugin.open', mock.mock_open(read_data=content), create=True) as mock_open:
            with mock.patch('pytest_github.plugin.GitHubPytestPlugin') as mock_plugin:
                result = testdir.runpytest()

    # Assert py.test exit code
    assert result.ret == EXIT_NOTESTSCOLLECTED

    # Assert mock isfile called
    mock_isfile.assert_called_once_with('github.yml')

    # Assert mock open called on provided file
    mock_open.assert_called_once_with('github.yml', 'r')

    # Assert plugin initialized as expected
    mock_plugin.assert_called_once_with(None, None, completed_labels=[])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号