擅长:python、mysql、java
<p>使用<code>vcrpy-unittest</code>可以更容易地实现这一点,正如您可能猜测的那样,<code>vcrpy</code>和{<cd3>}之间的集成。在</p>
<p>你的例子如下:</p>
<pre><code>from vcr_unittest import VCRTestCase
class TestCloudAPI(VCRTestCase):
def test_get_api_token(self):
# real request and testing
def test_container_lifecycle(self):
# real request and testing
</code></pre>
<p>磁带会根据测试自动命名,并与测试文件一起保存在<code>cassettes</code>目录中。例如,这将创建两个文件:<code>cassettes/TestCloudAPI.test_get_api_token.yaml</code>和{<cd6>}。在</p>
<p>目录和命名可以通过重写两个方法来定制:<code>_get_cassette_library_dir</code>和<code>_get_cassette_name</code>,但这可能不是必需的。在</p>
<p><code>vcrpy-unittest</code>位于github的<a href="https://github.com/agriffis/vcrpy-unittest" rel="nofollow">https://github.com/agriffis/vcrpy-unittest</a>,PyPI位于<a href="https://pypi.python.org/pypi/vcrpy-unittest" rel="nofollow">https://pypi.python.org/pypi/vcrpy-unittest</a></p>