管理vcr.py磁带的插件
pytest-vcr的Python项目详细描述
管理VCR.py磁带的py.test插件。
快速启动
安装插件:
pip install pytest-vcr
为测试添加批注:
@pytest.mark.vcr()deftest_iana():response=urlopen('http://www.iana.org/domains/reserved').read()assertb'Example domains'inresponse
就这样! 第一次运行时,将在测试文件旁边创建一个新文件cassettes/test_iana.yaml。 此文件应提交给VCS。
有关更多示例和配置选项,请参见documention on ReadTheDocs。