test_main_build_scenarios.py 文件源码

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

项目:sphinxcontrib-versioning 作者: Robpol86 项目源码 文件源码
def test_error_bad_path(tmpdir):
    """Test handling of bad paths.

    :param tmpdir: pytest fixture.
    """
    with pytest.raises(CalledProcessError) as exc:
        pytest.run(tmpdir, ['sphinx-versioning', '-N', '-c', 'unknown', 'build', '.', str(tmpdir)])
    assert 'Directory "unknown" does not exist.' in exc.value.output

    tmpdir.ensure('is_file')
    with pytest.raises(CalledProcessError) as exc:
        pytest.run(tmpdir, ['sphinx-versioning', '-N', '-c', 'is_file', 'build', '.', str(tmpdir)])
    assert 'Directory "is_file" is a file.' in exc.value.output

    with pytest.raises(CalledProcessError) as exc:
        pytest.run(tmpdir, ['sphinx-versioning', '-N', 'build', '.', str(tmpdir)])
    assert 'Failed to find local git repository root in {}.'.format(repr(str(tmpdir))) in exc.value.output

    repo = tmpdir.ensure_dir('repo')
    pytest.run(repo, ['git', 'init'])
    empty = tmpdir.ensure_dir('empty1857')
    with pytest.raises(CalledProcessError) as exc:
        pytest.run(repo, ['sphinx-versioning', '-N', '-g', str(empty), 'build', '.', str(tmpdir)])
    assert 'Failed to find local git repository root in' in exc.value.output
    assert 'empty1857' in exc.value.output
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号